@defillama/sdk 5.0.234 → 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 (63) hide show
  1. package/build/ChainApi.d.ts +23 -1
  2. package/build/ChainApi.js +1 -0
  3. package/build/abi/multicall3.js +4 -0
  4. package/build/chains/algorand.d.ts +277 -0
  5. package/build/chains/algorand.js +618 -0
  6. package/build/chains/aptos.d.ts +230 -0
  7. package/build/chains/aptos.js +612 -0
  8. package/build/chains/cardano.d.ts +242 -0
  9. package/build/chains/cardano.js +407 -0
  10. package/build/chains/cosmos.d.ts +252 -0
  11. package/build/chains/cosmos.js +618 -0
  12. package/build/chains/icp.d.ts +235 -0
  13. package/build/chains/icp.js +1040 -0
  14. package/build/chains/index.d.ts +23 -0
  15. package/build/chains/index.js +59 -0
  16. package/build/chains/near.d.ts +192 -0
  17. package/build/chains/near.js +446 -0
  18. package/build/chains/rpc.d.ts +125 -0
  19. package/build/chains/rpc.js +326 -0
  20. package/build/chains/starknet.d.ts +205 -0
  21. package/build/chains/starknet.js +884 -0
  22. package/build/chains/stellar.d.ts +410 -0
  23. package/build/chains/stellar.js +1082 -0
  24. package/build/chains/substrate.d.ts +333 -0
  25. package/build/chains/substrate.js +1042 -0
  26. package/build/chains/sui.d.ts +365 -0
  27. package/build/chains/sui.js +1135 -0
  28. package/build/chains/svm.d.ts +340 -0
  29. package/build/chains/svm.js +760 -0
  30. package/build/chains/tezos.d.ts +225 -0
  31. package/build/chains/tezos.js +412 -0
  32. package/build/chains/ton.d.ts +353 -0
  33. package/build/chains/ton.js +788 -0
  34. package/build/chains/tron.d.ts +45 -0
  35. package/build/chains/tron.js +110 -0
  36. package/build/chains/utxo.d.ts +202 -0
  37. package/build/chains/utxo.js +592 -0
  38. package/build/chains/xrpl.d.ts +179 -0
  39. package/build/chains/xrpl.js +467 -0
  40. package/build/index.d.ts +2 -1
  41. package/build/index.js +3 -1
  42. package/build/providers.json +1 -1
  43. package/build/util/chainUtils/data.json +16 -1
  44. package/build/util/chainUtils/index.d.ts +1 -0
  45. package/build/util/chainUtils/index.js +23 -0
  46. package/build/util/common.js +2 -3
  47. package/build/util/cosmos.d.ts +1 -11
  48. package/build/util/cosmos.js +6 -66
  49. package/build/util/env.js +1 -0
  50. package/build/util/indexer.compatibility.d.ts +6 -0
  51. package/build/util/indexer.compatibility.js +64 -0
  52. package/build/util/indexer.d.ts +24 -2
  53. package/build/util/indexer.js +215 -285
  54. package/build/util/indexerSql.d.ts +8 -1
  55. package/build/util/indexerSql.js +53 -22
  56. package/build/util/logs.decode.shared.js +5 -4
  57. package/build/util/logs.js +1 -2
  58. package/build/util/transactions.d.ts +23 -1
  59. package/build/util/updateChainLabels.d.ts +1 -0
  60. package/build/util/updateChainLabels.js +5 -0
  61. package/build/util/updateProviderList.js +40 -17
  62. package/package.json +20 -7
  63. package/README.md +0 -41
@@ -0,0 +1,252 @@
1
+ import { Endpoints } from "./rpc";
2
+ /** Default LCD endpoints. Comma separated values are fallbacks, tried in order. */
3
+ export declare const DEFAULT_ENDPOINTS: Record<string, string>;
4
+ /**
5
+ * Module-specific REST prefix used by `queryV1Beta1` (e.g. `/osmosis/gamm/...`,
6
+ * `/kava/hard/...`). Standard sdk modules (bank, staking, ...) always live under
7
+ * `/cosmos/`, use `query` / `getBalances` / `totalSupply` for those.
8
+ */
9
+ export declare const chainSubpaths: Record<string, string>;
10
+ /** Some contract calls need an endpoint with a higher gas limit. contract address -> endpoint */
11
+ export declare const highGasLimitEndpoints: Record<string, string>;
12
+ /**
13
+ * Cosmos chains that also expose an EVM JSON-RPC. For these `<CHAIN>_RPC` is the
14
+ * EVM url and is never used as LCD, and `isCosmosChain` stays false so block
15
+ * lookups keep going through the EVM provider (same as before this module).
16
+ */
17
+ export declare const EVM_COSMOS_CHAINS: string[];
18
+ /**
19
+ * Chains always treated as cosmos chains by `isCosmosChain` (legacy list from
20
+ * util/cosmos.ts plus the pure cosmos chains of the adapters map).
21
+ */
22
+ export declare const ibcChains: string[];
23
+ /** bech32 human readable prefix per chain (falls back to the chain name) */
24
+ export declare const BECH32_PREFIXES: Record<string, string>;
25
+ export declare const isCosmosChain: (chain: string) => boolean;
26
+ /** Resolve the LCD endpoint list for a chain, see the module header for the order. */
27
+ export declare function getEndpoints({ chain }: {
28
+ chain: string;
29
+ }): string[];
30
+ /** First LCD endpoint. `contract` switches to a high gas limit endpoint when one is configured for it. */
31
+ export declare function getEndpoint({ chain, contract }: {
32
+ chain: string;
33
+ contract?: string;
34
+ }): string;
35
+ /** base64 encode a cosmwasm query message (objects are JSON.stringified first) */
36
+ export declare function encodeQuery(data: any): string;
37
+ /**
38
+ * Heuristic: cosmwasm contract addresses are 32 byte bech32 strings (~63 chars)
39
+ * while accounts are 20 bytes (~43 chars).
40
+ */
41
+ export declare function isContractAddress(chain: string, address: string): boolean;
42
+ /** Cosmos block times carry nanosecond precision; trim to millis before parsing. */
43
+ export declare function parseBlockTime(iso: string): number;
44
+ /**
45
+ * Explicit "this height is pruned / does not exist" answers from a node. A bare 404
46
+ * is NOT enough: LCDs also answer 404 for routes they do not serve (older chains
47
+ * without `/cosmos/base/tendermint/v1beta1`), and that case must fall back to the
48
+ * legacy `/blocks/{h}` route instead of being reported as a pruned block.
49
+ */
50
+ export declare function isPrunedHeightError(e: any): boolean;
51
+ export interface QueryOptions {
52
+ chain: string;
53
+ /** path relative to the LCD root, e.g. `cosmos/bank/v1beta1/supply` */
54
+ path: string;
55
+ /** height for historical state, sent as `x-cosmos-block-height` */
56
+ block?: number | string;
57
+ /** query string params */
58
+ params?: Record<string, any>;
59
+ /** explicit endpoint(s), overrides chain resolution */
60
+ endpoint?: Endpoints;
61
+ /** used to pick a high gas limit endpoint */
62
+ contract?: string;
63
+ timeout?: number;
64
+ retries?: number;
65
+ }
66
+ /** GET `<lcd>/<path>`; rotates over the chain endpoints on failure. Returns the raw JSON body. */
67
+ export declare function query({ chain, path, block, params, endpoint, contract, timeout, retries }: QueryOptions): Promise<any>;
68
+ /**
69
+ * GET `<lcd>/<subpath>/<url>` where subpath is `chainSubpaths[chain]` or `cosmos`
70
+ * (module specific queries such as `gamm/v1beta1/pools` on osmosis).
71
+ */
72
+ export declare function queryV1Beta1({ chain, url, block, paginationKey, subpath, endpoint }: {
73
+ chain: string;
74
+ url: string;
75
+ block?: number | string;
76
+ paginationKey?: string;
77
+ subpath?: string;
78
+ endpoint?: Endpoints;
79
+ }): Promise<any>;
80
+ /**
81
+ * Follow `pagination.next_key` over `path` and return the concatenated `dataKey`
82
+ * items. When `dataKey` is omitted the first array field of the response is used.
83
+ */
84
+ export declare function paginate({ chain, path, dataKey, limit, block, endpoint }: {
85
+ chain: string;
86
+ path: string;
87
+ dataKey?: string;
88
+ limit?: number;
89
+ block?: number | string;
90
+ endpoint?: Endpoints;
91
+ }): Promise<any[]>;
92
+ /** Auto-paginating `queryV1Beta1`; returns the concatenated `dataKey` items. */
93
+ export declare function queryV1Beta1All({ chain, url, dataKey, limit, block, subpath, endpoint }: {
94
+ chain: string;
95
+ url: string;
96
+ dataKey?: string;
97
+ limit?: number;
98
+ block?: number | string;
99
+ subpath?: string;
100
+ endpoint?: Endpoints;
101
+ }): Promise<any[]>;
102
+ export interface Coin {
103
+ denom: string;
104
+ amount: string;
105
+ }
106
+ /** All native balances of `owner` (every page). */
107
+ export declare function getBalances({ chain, owner, block }: {
108
+ chain: string;
109
+ owner: string;
110
+ block?: number | string;
111
+ }): Promise<Coin[]>;
112
+ /** Native balance of one denom, `"0"` when the account does not hold it. */
113
+ export declare function getDenomBalance({ chain, denom, owner, block }: {
114
+ chain: string;
115
+ denom: string;
116
+ owner: string;
117
+ block?: number | string;
118
+ }): Promise<string>;
119
+ /** Balance of a cw20 contract (`token` looks like a contract address) or a native denom. */
120
+ export declare function getBalance({ chain, token, owner, block }: {
121
+ chain: string;
122
+ token: string;
123
+ owner: string;
124
+ block?: number | string;
125
+ }): Promise<string>;
126
+ /** Balance for an astroport style asset info (`{ native_token: { denom } }` / `{ token: { contract_addr } }`) or a plain string. */
127
+ export declare function getTokenBalance({ chain, token, owner, block }: {
128
+ chain: string;
129
+ token: any;
130
+ owner: string;
131
+ block?: number | string;
132
+ }): Promise<string>;
133
+ /** Total supply of a native denom via `bank/v1beta1/supply/by_denom`. */
134
+ export declare function totalSupply({ chain, denom, block }: {
135
+ chain: string;
136
+ denom: string;
137
+ block?: number | string;
138
+ }): Promise<string>;
139
+ /** Total supply of every denom (all pages). */
140
+ export declare function getSupplyAll({ chain, block }: {
141
+ chain: string;
142
+ block?: number | string;
143
+ }): Promise<Coin[]>;
144
+ /** cosmwasm smart query; `data` is the query message (object or JSON string). Returns the `data` field. */
145
+ export declare function queryContract({ chain, contract, data, block, endpoint }: {
146
+ chain: string;
147
+ contract: string;
148
+ data: any;
149
+ block?: number | string;
150
+ endpoint?: Endpoints;
151
+ }): Promise<any>;
152
+ /** Same as `queryContract`; every configured endpoint is tried before giving up. */
153
+ export declare function queryContractWithRetries({ chain, contract, data, block }: {
154
+ chain: string;
155
+ contract: string;
156
+ data: any;
157
+ block?: number | string;
158
+ }): Promise<any>;
159
+ /** Run the same smart query against many contracts. Results keep the input order; failures resolve to `undefined` when `permitFailure` is set. */
160
+ export declare function queryManyContracts({ chain, contracts, data, block, permitFailure, concurrency }: {
161
+ chain: string;
162
+ contracts: string[];
163
+ data: any;
164
+ block?: number | string;
165
+ permitFailure?: boolean;
166
+ concurrency?: number;
167
+ }): Promise<any[]>;
168
+ /** All contract addresses instantiated from `codeId` (all pages). */
169
+ export declare function queryContracts({ chain, codeId, limit }: {
170
+ chain: string;
171
+ codeId: number | string;
172
+ limit?: number;
173
+ }): Promise<string[]>;
174
+ /** Legacy (terra classic) `/wasm/contracts/{contract}/store?query_msg=` query. Returns the `result` field. */
175
+ export declare function queryContractStore({ chain, contract, queryParam, block }: {
176
+ chain: string;
177
+ contract: string;
178
+ queryParam: any;
179
+ block?: number | string;
180
+ }): Promise<any>;
181
+ /** `/cosmwasm/wasm/v1/contract/{contract}` -> `contract_info` (code_id, creator, admin, label, ...). */
182
+ export declare function getContractInfo({ chain, contract }: {
183
+ chain: string;
184
+ contract: string;
185
+ }): Promise<any>;
186
+ /** cw20 `token_info` -> { name, symbol, decimals, total_supply } */
187
+ export declare function getTokenInfo({ chain, contract, block }: {
188
+ chain: string;
189
+ contract: string;
190
+ block?: number | string;
191
+ }): Promise<{
192
+ name: string;
193
+ symbol: string;
194
+ decimals: number;
195
+ total_supply: string;
196
+ }>;
197
+ /** cw20 `minter` -> minter address (the pair contract for LP tokens) */
198
+ export declare function getLpMinter({ chain, token, block }: {
199
+ chain: string;
200
+ token: string;
201
+ block?: number | string;
202
+ }): Promise<string>;
203
+ export interface CosmosBlock {
204
+ number: number;
205
+ timestamp: number;
206
+ }
207
+ /** Block header via `/cosmos/base/tendermint/v1beta1/blocks/{h}`, falling back to the legacy `/blocks/{h}` route. */
208
+ export declare function getBlock({ chain, height }: {
209
+ chain: string;
210
+ height?: number | string;
211
+ }): Promise<CosmosBlock>;
212
+ export declare function getLatestBlock({ chain }: {
213
+ chain: string;
214
+ }): Promise<CosmosBlock>;
215
+ /** Block time in seconds, `null` when the height is pruned / unavailable. Cached per chain. */
216
+ export declare function getBlockTime({ chain, height }: {
217
+ chain: string;
218
+ height: number;
219
+ }): Promise<number | null>;
220
+ /**
221
+ * Largest height whose block time is <= `timestamp` (binary search over block
222
+ * headers, pruned heights count as "too old"). Throws when every retained block is
223
+ * newer than `timestamp`.
224
+ */
225
+ export declare function getBlockAtTimestamp({ chain, timestamp }: {
226
+ chain: string;
227
+ timestamp: number;
228
+ }): Promise<CosmosBlock>;
229
+ export declare function getCosmosBlock(block?: number | string, chain?: string): Promise<CosmosBlock>;
230
+ export declare function getCosmosProvider(chain: string): {
231
+ getBlock: (block?: number | string) => Promise<CosmosBlock>;
232
+ };
233
+ export declare const tendermint: {
234
+ /** `<CHAIN>_TENDERMINT_RPC`, then `https://rpc.cosmos.directory/<chain>` */
235
+ getEndpoints({ chain }: {
236
+ chain: string;
237
+ }): string[];
238
+ /** JSON-RPC `status` -> { node_info, sync_info: { latest_block_height, latest_block_time, earliest_block_height, ... } } */
239
+ getStatus({ chain }: {
240
+ chain: string;
241
+ }): Promise<any>;
242
+ /** JSON-RPC `block` -> { block_id, block: { header, data, ... } } (latest when height is omitted) */
243
+ getTendermintBlock({ chain, height }: {
244
+ chain: string;
245
+ height?: number | string;
246
+ }): Promise<any>;
247
+ /** `{ number, timestamp }` from the tendermint `block` call */
248
+ getBlock({ chain, height }: {
249
+ chain: string;
250
+ height?: number | string;
251
+ }): Promise<CosmosBlock>;
252
+ };