@covalenthq/client-sdk 0.1.2 → 0.1.4

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 (66) hide show
  1. package/README.md +44 -31
  2. package/dist/services/BalanceService.d.ts +390 -0
  3. package/dist/services/BalanceService.js +618 -0
  4. package/dist/services/BalanceService.js.map +1 -0
  5. package/dist/services/BaseService.d.ts +303 -0
  6. package/dist/services/BaseService.js +691 -0
  7. package/dist/services/BaseService.js.map +1 -0
  8. package/dist/services/Client.d.ts +22 -0
  9. package/dist/services/Client.js +26 -0
  10. package/dist/services/Client.js.map +1 -0
  11. package/dist/services/NftService.d.ts +428 -0
  12. package/dist/services/NftService.js +981 -0
  13. package/dist/services/NftService.js.map +1 -0
  14. package/dist/services/PricingService.d.ts +75 -0
  15. package/dist/services/PricingService.js +126 -0
  16. package/dist/services/PricingService.js.map +1 -0
  17. package/dist/services/SecurityService.d.ts +96 -0
  18. package/dist/services/SecurityService.js +122 -0
  19. package/dist/services/SecurityService.js.map +1 -0
  20. package/dist/services/TransactionService.d.ts +222 -0
  21. package/dist/services/TransactionService.js +433 -0
  22. package/dist/services/TransactionService.js.map +1 -0
  23. package/dist/services/XykService.d.ts +529 -0
  24. package/dist/services/XykService.js +1000 -0
  25. package/dist/services/XykService.js.map +1 -0
  26. package/dist/services/index.js.map +1 -0
  27. package/dist/util/ApiHelpers.d.ts +1 -0
  28. package/dist/util/ApiHelpers.js +15 -0
  29. package/dist/util/ApiHelpers.js.map +1 -0
  30. package/dist/util/backoff.d.ts +9 -0
  31. package/dist/util/backoff.js +25 -0
  32. package/dist/util/backoff.js.map +1 -0
  33. package/package.json +11 -3
  34. package/dist/ApprovalService.d.ts +0 -59
  35. package/dist/ApprovalService.js +0 -52
  36. package/dist/ApprovalService.js.map +0 -1
  37. package/dist/BalancesService.d.ts +0 -189
  38. package/dist/BalancesService.js +0 -231
  39. package/dist/BalancesService.js.map +0 -1
  40. package/dist/BaseService.d.ts +0 -169
  41. package/dist/BaseService.js +0 -276
  42. package/dist/BaseService.js.map +0 -1
  43. package/dist/Client.d.ts +0 -24
  44. package/dist/Client.js +0 -30
  45. package/dist/Client.js.map +0 -1
  46. package/dist/LogEventService.d.ts +0 -62
  47. package/dist/LogEventService.js +0 -75
  48. package/dist/LogEventService.js.map +0 -1
  49. package/dist/NameResolverService.d.ts +0 -33
  50. package/dist/NameResolverService.js +0 -52
  51. package/dist/NameResolverService.js.map +0 -1
  52. package/dist/NftService.d.ts +0 -271
  53. package/dist/NftService.js +0 -528
  54. package/dist/NftService.js.map +0 -1
  55. package/dist/PricingService.d.ts +0 -52
  56. package/dist/PricingService.js +0 -65
  57. package/dist/PricingService.js.map +0 -1
  58. package/dist/TransactionsService.d.ts +0 -126
  59. package/dist/TransactionsService.js +0 -230
  60. package/dist/TransactionsService.js.map +0 -1
  61. package/dist/XykService.d.ts +0 -383
  62. package/dist/XykService.js +0 -467
  63. package/dist/XykService.js.map +0 -1
  64. package/dist/index.js.map +0 -1
  65. /package/dist/{index.d.ts → services/index.d.ts} +0 -0
  66. /package/dist/{index.js → services/index.js} +0 -0
@@ -0,0 +1,1000 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XykService = exports.Response = void 0;
4
+ const backoff_1 = require("../util/backoff");
5
+ const ApiHelpers_1 = require("../util/ApiHelpers");
6
+ class PoolResponse {
7
+ constructor(data) {
8
+ this.updated_at = data.updated_at;
9
+ this.chain_id = data.chain_id;
10
+ this.chain_name = data.chain_name;
11
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new Pool(itemData)) : null;
12
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
13
+ }
14
+ }
15
+ class Pool {
16
+ constructor(data) {
17
+ this.exchange = data.exchange;
18
+ this.swap_count_24h = data.swap_count_24h;
19
+ this.total_liquidity_quote = data.total_liquidity_quote;
20
+ this.volume_24h_quote = data.volume_24h_quote;
21
+ this.fee_24h_quote = data.fee_24h_quote;
22
+ this.total_supply = data.total_supply !== null ? BigInt(data.total_supply) : null;
23
+ this.quote_rate = data.quote_rate;
24
+ this.chain_name = data.chain_name;
25
+ this.chain_id = data.chain_id;
26
+ this.dex_name = data.dex_name;
27
+ this.volume_7d_quote = data.volume_7d_quote;
28
+ this.annualized_fee = data.annualized_fee;
29
+ this.token_0 = data.token_0 && data.token_0 !== null ? new Token(data.token_0) : null;
30
+ this.token_1 = data.token_1 && data.token_1 !== null ? new Token(data.token_1) : null;
31
+ }
32
+ }
33
+ class Pagination {
34
+ constructor(data) {
35
+ this.has_more = data.has_more;
36
+ this.page_number = data.page_number;
37
+ this.page_size = data.page_size;
38
+ this.total_count = data.total_count;
39
+ }
40
+ }
41
+ class Token {
42
+ constructor(data) {
43
+ this.contract_address = data.contract_address;
44
+ this.contract_name = data.contract_name;
45
+ this.volume_in_24h = data.volume_in_24h;
46
+ this.volume_out_24h = data.volume_out_24h;
47
+ this.quote_rate = data.quote_rate;
48
+ this.reserve = data.reserve;
49
+ this.logo_url = data.logo_url;
50
+ this.contract_ticker_symbol = data.contract_ticker_symbol;
51
+ this.contract_decimals = data.contract_decimals;
52
+ this.volume_in_7d = data.volume_in_7d;
53
+ this.volume_out_7d = data.volume_out_7d;
54
+ }
55
+ }
56
+ class PoolByAddressResponse {
57
+ constructor(data) {
58
+ this.updated_at = data.updated_at;
59
+ this.chain_id = data.chain_id;
60
+ this.chain_name = data.chain_name;
61
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new PoolWithTimeseries(itemData)) : null;
62
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
63
+ }
64
+ }
65
+ class PoolWithTimeseries {
66
+ constructor(data) {
67
+ this.exchange = data.exchange;
68
+ this.swap_count_24h = data.swap_count_24h;
69
+ this.total_liquidity_quote = data.total_liquidity_quote;
70
+ this.volume_24h_quote = data.volume_24h_quote;
71
+ this.fee_24h_quote = data.fee_24h_quote;
72
+ this.total_supply = data.total_supply !== null ? BigInt(data.total_supply) : null;
73
+ this.quote_rate = data.quote_rate;
74
+ this.chain_id = data.chain_id;
75
+ this.dex_name = data.dex_name;
76
+ this.volume_7d_quote = data.volume_7d_quote;
77
+ this.annualized_fee = data.annualized_fee;
78
+ this.token_0_reserve_quote = data.token_0_reserve_quote;
79
+ this.token_1_reserve_quote = data.token_1_reserve_quote;
80
+ this.token_0 = data.token_0 && data.token_0 !== null ? new Token(data.token_0) : null;
81
+ this.token_1 = data.token_1 && data.token_1 !== null ? new Token(data.token_1) : null;
82
+ this.volume_timeseries_7d = data.volume_timeseries_7d && data.volume_timeseries_7d !== null ? data.volume_timeseries_7d.map((itemData) => new VolumeTimeseries(itemData)) : null;
83
+ this.volume_timeseries_30d = data.volume_timeseries_30d && data.volume_timeseries_30d !== null ? data.volume_timeseries_30d.map((itemData) => new VolumeTimeseries(itemData)) : null;
84
+ this.liquidity_timeseries_7d = data.liquidity_timeseries_7d && data.liquidity_timeseries_7d !== null ? data.liquidity_timeseries_7d.map((itemData) => new LiquidityTimeseries(itemData)) : null;
85
+ this.liquidity_timeseries_30d = data.liquidity_timeseries_30d && data.liquidity_timeseries_30d !== null ? data.liquidity_timeseries_30d.map((itemData) => new LiquidityTimeseries(itemData)) : null;
86
+ this.price_timeseries_7d = data.price_timeseries_7d && data.price_timeseries_7d !== null ? data.price_timeseries_7d.map((itemData) => new PriceTimeseries(itemData)) : null;
87
+ this.price_timeseries_30d = data.price_timeseries_30d && data.price_timeseries_30d !== null ? data.price_timeseries_30d.map((itemData) => new PriceTimeseries(itemData)) : null;
88
+ }
89
+ }
90
+ class VolumeTimeseries {
91
+ constructor(data) {
92
+ this.dex_name = data.dex_name;
93
+ this.chain_id = data.chain_id;
94
+ this.dt = data.dt;
95
+ this.exchange = data.exchange;
96
+ this.sum_amount_0_in = data.sum_amount_0_in;
97
+ this.sum_amount_0_out = data.sum_amount_0_out;
98
+ this.sum_amount_1_in = data.sum_amount_1_in;
99
+ this.sum_amount_1_out = data.sum_amount_1_out;
100
+ this.volume_quote = data.volume_quote;
101
+ this.token_0_quote_rate = data.token_0_quote_rate;
102
+ this.token_1_quote_rate = data.token_1_quote_rate;
103
+ this.swap_count_24 = data.swap_count_24;
104
+ }
105
+ }
106
+ class LiquidityTimeseries {
107
+ constructor(data) {
108
+ this.dex_name = data.dex_name;
109
+ this.chain_id = data.chain_id;
110
+ this.dt = data.dt;
111
+ this.exchange = data.exchange;
112
+ this.r0_c = data.r0_c;
113
+ this.r1_c = data.r1_c;
114
+ this.liquidity_quote = data.liquidity_quote;
115
+ this.token_0_quote_rate = data.token_0_quote_rate;
116
+ this.token_1_quote_rate = data.token_1_quote_rate;
117
+ }
118
+ }
119
+ class PriceTimeseries {
120
+ constructor(data) {
121
+ this.dex_name = data.dex_name;
122
+ this.chain_id = data.chain_id;
123
+ this.dt = data.dt;
124
+ this.exchange = data.exchange;
125
+ this.price_of_token_0_in_token_1 = data.price_of_token_0_in_token_1;
126
+ this.price_of_token_0_in_token_1_description = data.price_of_token_0_in_token_1_description;
127
+ this.price_of_token_1_in_token_0 = data.price_of_token_1_in_token_0;
128
+ this.price_of_token_1_in_token_0_description = data.price_of_token_1_in_token_0_description;
129
+ this.quote_currency = data.quote_currency;
130
+ this.price_of_token_0_in_quote_currency = data.price_of_token_0_in_quote_currency;
131
+ this.price_of_token_1_in_quote_currency = data.price_of_token_1_in_quote_currency;
132
+ }
133
+ }
134
+ class AddressExchangeBalancesResponse {
135
+ constructor(data) {
136
+ this.address = data.address;
137
+ this.updated_at = data.updated_at;
138
+ this.chain_id = data.chain_id;
139
+ this.chain_name = data.chain_name;
140
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new UniswapLikeBalanceItem(itemData)) : null;
141
+ }
142
+ }
143
+ class UniswapLikeBalanceItem {
144
+ constructor(data) {
145
+ this.token_0 = data.token_0 && data.token_0 !== null ? new UniswapLikeToken(data.token_0) : null;
146
+ this.token_1 = data.token_1 && data.token_1 !== null ? new UniswapLikeToken(data.token_1) : null;
147
+ this.pool_token = data.pool_token && data.pool_token !== null ? new UniswapLikeTokenWithSupply(data.pool_token) : null;
148
+ }
149
+ }
150
+ class UniswapLikeToken {
151
+ constructor(data) {
152
+ this.contract_decimals = data.contract_decimals;
153
+ this.contract_ticker_symbol = data.contract_ticker_symbol;
154
+ this.contract_address = data.contract_address;
155
+ this.logo_url = data.logo_url;
156
+ this.balance = data.balance !== null ? BigInt(data.balance) : null;
157
+ this.quote = data.quote;
158
+ this.quote_rate = data.quote_rate;
159
+ }
160
+ }
161
+ class UniswapLikeTokenWithSupply {
162
+ constructor(data) {
163
+ this.contract_decimals = data.contract_decimals;
164
+ this.contract_ticker_symbol = data.contract_ticker_symbol;
165
+ this.contract_address = data.contract_address;
166
+ this.logo_url = data.logo_url;
167
+ this.balance = data.balance !== null ? BigInt(data.balance) : null;
168
+ this.quote = data.quote;
169
+ this.quote_rate = data.quote_rate;
170
+ this.total_supply = data.total_supply !== null ? BigInt(data.total_supply) : null;
171
+ }
172
+ }
173
+ class NetworkExchangeTokensResponse {
174
+ constructor(data) {
175
+ this.updated_at = data.updated_at;
176
+ this.chain_id = data.chain_id;
177
+ this.chain_name = data.chain_name;
178
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new TokenV2Volume(itemData)) : null;
179
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
180
+ }
181
+ }
182
+ class TokenV2Volume {
183
+ constructor(data) {
184
+ this.chain_name = data.chain_name;
185
+ this.chain_id = data.chain_id;
186
+ this.dex_name = data.dex_name;
187
+ this.contract_address = data.contract_address;
188
+ this.contract_name = data.contract_name;
189
+ this.total_liquidity = data.total_liquidity;
190
+ this.total_volume24h = data.total_volume24h;
191
+ this.logo_url = data.logo_url;
192
+ this.contract_ticker_symbol = data.contract_ticker_symbol;
193
+ this.contract_decimals = data.contract_decimals;
194
+ this.swap_count_24h = data.swap_count_24h;
195
+ this.quote_rate = data.quote_rate;
196
+ this.total_liquidity_quote = data.total_liquidity_quote;
197
+ this.total_volume_24h_quote = data.total_volume_24h_quote;
198
+ }
199
+ }
200
+ class SupportedDexesResponse {
201
+ constructor(data) {
202
+ this.updated_at = data.updated_at;
203
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new SupportedDex(itemData)) : null;
204
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
205
+ }
206
+ }
207
+ class SupportedDex {
208
+ constructor(data) {
209
+ this.chain_id = data.chain_id;
210
+ this.chain_name = data.chain_name;
211
+ this.dex_name = data.dex_name;
212
+ this.factory_contract_address = data.factory_contract_address;
213
+ this.router_contract_addresses = data.router_contract_addresses;
214
+ this.swap_fee = data.swap_fee;
215
+ }
216
+ }
217
+ class SingleNetworkExchangeTokenResponse {
218
+ constructor(data) {
219
+ this.updated_at = data.updated_at;
220
+ this.chain_id = data.chain_id;
221
+ this.chain_name = data.chain_name;
222
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new PoolWithTimeseries(itemData)) : null;
223
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
224
+ }
225
+ }
226
+ class TransactionsForAccountAddressResponse {
227
+ constructor(data) {
228
+ this.updated_at = data.updated_at;
229
+ this.chain_id = data.chain_id;
230
+ this.chain_name = data.chain_name;
231
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new ExchangeTransaction(itemData)) : null;
232
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
233
+ }
234
+ }
235
+ class ExchangeTransaction {
236
+ constructor(data) {
237
+ this.block_signed_at = data.block_signed_at;
238
+ this.tx_hash = data.tx_hash;
239
+ this.act = data.act;
240
+ this.address = data.address;
241
+ this.amount0 = data.amount0;
242
+ this.amount1 = data.amount1;
243
+ this.amount0_in = data.amount0_in;
244
+ this.amount0_out = data.amount0_out;
245
+ this.amount1_out = data.amount1_out;
246
+ this.to_address = data.to_address;
247
+ this.from_address = data.from_address;
248
+ this.sender_address = data.sender_address;
249
+ this.total_quote = data.total_quote;
250
+ this.token_0_quote_rate = data.token_0_quote_rate;
251
+ this.token_1_quote_rate = data.token_1_quote_rate;
252
+ this.token_0 = data.token_0 && data.token_0 !== null ? new PoolToken(data.token_0) : null;
253
+ this.token_1 = data.token_1 && data.token_1 !== null ? new PoolToken(data.token_1) : null;
254
+ }
255
+ }
256
+ class PoolToken {
257
+ constructor(data) {
258
+ this.contract_decimals = data.contract_decimals;
259
+ this.contract_name = data.contract_name;
260
+ this.contract_ticker_symbol = data.contract_ticker_symbol;
261
+ this.contract_address = data.contract_address;
262
+ this.supports_erc = data.supports_erc;
263
+ this.logo_url = data.logo_url;
264
+ }
265
+ }
266
+ class TransactionsForTokenAddressResponse {
267
+ constructor(data) {
268
+ this.updated_at = data.updated_at;
269
+ this.chain_id = data.chain_id;
270
+ this.chain_name = data.chain_name;
271
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new ExchangeTransaction(itemData)) : null;
272
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
273
+ }
274
+ }
275
+ class TransactionsForExchangeResponse {
276
+ constructor(data) {
277
+ this.updated_at = data.updated_at;
278
+ this.chain_id = data.chain_id;
279
+ this.chain_name = data.chain_name;
280
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new ExchangeTransaction(itemData)) : null;
281
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
282
+ }
283
+ }
284
+ class EcosystemChartDataResponse {
285
+ constructor(data) {
286
+ this.updated_at = data.updated_at;
287
+ this.chain_id = data.chain_id;
288
+ this.chain_name = data.chain_name;
289
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new UniswapLikeEcosystemCharts(itemData)) : null;
290
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
291
+ }
292
+ }
293
+ class UniswapLikeEcosystemCharts {
294
+ constructor(data) {
295
+ this.dex_name = data.dex_name;
296
+ this.chain_id = data.chain_id;
297
+ this.quote_currency = data.quote_currency;
298
+ this.gas_token_price_quote = data.gas_token_price_quote;
299
+ this.total_swaps24h = data.total_swaps24h;
300
+ this.total_active_pairs7d = data.total_active_pairs7d;
301
+ this.total_fees24h = data.total_fees24h;
302
+ this.volume_chart7d = data.volume_chart7d && data.volume_chart7d !== null ? data.volume_chart7d.map((itemData) => new VolumeEcosystemChart(itemData)) : null;
303
+ this.volume_chart30d = data.volume_chart30d && data.volume_chart30d !== null ? data.volume_chart30d.map((itemData) => new VolumeEcosystemChart(itemData)) : null;
304
+ this.liquidity_chart7d = data.liquidity_chart7d && data.liquidity_chart7d !== null ? data.liquidity_chart7d.map((itemData) => new LiquidityEcosystemChart(itemData)) : null;
305
+ this.liquidity_chart30d = data.liquidity_chart30d && data.liquidity_chart30d !== null ? data.liquidity_chart30d.map((itemData) => new LiquidityEcosystemChart(itemData)) : null;
306
+ }
307
+ }
308
+ class VolumeEcosystemChart {
309
+ constructor(data) {
310
+ this.dex_name = data.dex_name;
311
+ this.chain_id = data.chain_id;
312
+ this.dt = data.dt;
313
+ this.quote_currency = data.quote_currency;
314
+ this.volume_quote = data.volume_quote;
315
+ this.swap_count_24 = data.swap_count_24;
316
+ }
317
+ }
318
+ class LiquidityEcosystemChart {
319
+ constructor(data) {
320
+ this.dex_name = data.dex_name;
321
+ this.chain_id = data.chain_id;
322
+ this.dt = data.dt;
323
+ this.quote_currency = data.quote_currency;
324
+ this.liquidity_quote = data.liquidity_quote;
325
+ }
326
+ }
327
+ class HealthDataResponse {
328
+ constructor(data) {
329
+ this.updated_at = data.updated_at;
330
+ this.chain_id = data.chain_id;
331
+ this.chain_name = data.chain_name;
332
+ this.items = data.items && data.items !== null ? data.items.map((itemData) => new HealthData(itemData)) : null;
333
+ this.pagination = data.pagination && data.pagination !== null ? new Pagination(data.pagination) : null;
334
+ }
335
+ }
336
+ class HealthData {
337
+ constructor(data) {
338
+ this.synced_block_height = data.synced_block_height;
339
+ this.synced_block_signed_at = data.synced_block_signed_at;
340
+ this.latest_block_height = data.latest_block_height;
341
+ this.latest_block_signed_at = data.latest_block_signed_at;
342
+ }
343
+ }
344
+ /**
345
+ * XYK APIs
346
+ *
347
+ */
348
+ class Response {
349
+ }
350
+ exports.Response = Response;
351
+ class XykService {
352
+ constructor(apiKey) {
353
+ this.apiKey = apiKey;
354
+ }
355
+ /**
356
+ *
357
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
358
+ * @param {string} dexName - The DEX name eg: `uniswap_v2`.
359
+ *
360
+ */
361
+ async getPools(chainName, dexName) {
362
+ let success = false;
363
+ let data;
364
+ let response;
365
+ const backoff = new backoff_1.ExponentialBackoff();
366
+ while (!success) {
367
+ try {
368
+ const urlParams = new URLSearchParams();
369
+ response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/?${urlParams}`, {
370
+ headers: {
371
+ "Authorization": `Bearer ${this.apiKey}`
372
+ }
373
+ });
374
+ data = await response.json();
375
+ if (data.error && data.error_code === 429) {
376
+ try {
377
+ await backoff.backOff();
378
+ }
379
+ catch (error) {
380
+ (0, ApiHelpers_1.checkAndModifyResponse)(data);
381
+ success = true;
382
+ return {
383
+ data: null,
384
+ error: data.error,
385
+ error_code: data ? data.error_code : response.status,
386
+ error_message: data ? data.error_message : "401 Authorization Required"
387
+ };
388
+ }
389
+ }
390
+ else {
391
+ const dataClass = new PoolResponse(data.data);
392
+ (0, ApiHelpers_1.checkAndModifyResponse)(dataClass);
393
+ success = true;
394
+ return {
395
+ data: dataClass,
396
+ error: data.error,
397
+ error_code: data ? data.error_code : response.status,
398
+ error_message: data ? data.error_message : "401 Authorization Required"
399
+ };
400
+ }
401
+ }
402
+ catch (error) {
403
+ success = true;
404
+ return {
405
+ data: null,
406
+ error: true,
407
+ error_code: data ? data.error_code : response.status,
408
+ error_message: data ? data.error_message : "401 Authorization Required"
409
+ };
410
+ }
411
+ }
412
+ }
413
+ /**
414
+ *
415
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
416
+ * @param {string} dexName - The DEX name eg: `uniswap_v2`.
417
+ * @param {string} poolAddress - The pool contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
418
+ *
419
+ */
420
+ async getPoolByAddress(chainName, dexName, poolAddress) {
421
+ let success = false;
422
+ let data;
423
+ let response;
424
+ const backoff = new backoff_1.ExponentialBackoff();
425
+ while (!success) {
426
+ try {
427
+ const urlParams = new URLSearchParams();
428
+ response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/address/${poolAddress}/?${urlParams}`, {
429
+ headers: {
430
+ "Authorization": `Bearer ${this.apiKey}`
431
+ }
432
+ });
433
+ data = await response.json();
434
+ if (data.error && data.error_code === 429) {
435
+ try {
436
+ await backoff.backOff();
437
+ }
438
+ catch (error) {
439
+ (0, ApiHelpers_1.checkAndModifyResponse)(data);
440
+ success = true;
441
+ return {
442
+ data: null,
443
+ error: data.error,
444
+ error_code: data ? data.error_code : response.status,
445
+ error_message: data ? data.error_message : "401 Authorization Required"
446
+ };
447
+ }
448
+ }
449
+ else {
450
+ const dataClass = new PoolByAddressResponse(data.data);
451
+ (0, ApiHelpers_1.checkAndModifyResponse)(dataClass);
452
+ success = true;
453
+ return {
454
+ data: dataClass,
455
+ error: data.error,
456
+ error_code: data ? data.error_code : response.status,
457
+ error_message: data ? data.error_message : "401 Authorization Required"
458
+ };
459
+ }
460
+ }
461
+ catch (error) {
462
+ success = true;
463
+ return {
464
+ data: null,
465
+ error: true,
466
+ error_code: data ? data.error_code : response.status,
467
+ error_message: data ? data.error_message : "401 Authorization Required"
468
+ };
469
+ }
470
+ }
471
+ }
472
+ /**
473
+ *
474
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
475
+ * @param {string} dexName - The DEX name eg: `uniswap_v2`.
476
+ * @param {string} accountAddress - The account address.
477
+ *
478
+ */
479
+ async getAddressExchangeBalances(chainName, dexName, accountAddress) {
480
+ let success = false;
481
+ let data;
482
+ let response;
483
+ const backoff = new backoff_1.ExponentialBackoff();
484
+ while (!success) {
485
+ try {
486
+ const urlParams = new URLSearchParams();
487
+ response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/address/${accountAddress}/balances/?${urlParams}`, {
488
+ headers: {
489
+ "Authorization": `Bearer ${this.apiKey}`
490
+ }
491
+ });
492
+ data = await response.json();
493
+ if (data.error && data.error_code === 429) {
494
+ try {
495
+ await backoff.backOff();
496
+ }
497
+ catch (error) {
498
+ (0, ApiHelpers_1.checkAndModifyResponse)(data);
499
+ success = true;
500
+ return {
501
+ data: null,
502
+ error: data.error,
503
+ error_code: data ? data.error_code : response.status,
504
+ error_message: data ? data.error_message : "401 Authorization Required"
505
+ };
506
+ }
507
+ }
508
+ else {
509
+ const dataClass = new AddressExchangeBalancesResponse(data.data);
510
+ (0, ApiHelpers_1.checkAndModifyResponse)(dataClass);
511
+ success = true;
512
+ return {
513
+ data: dataClass,
514
+ error: data.error,
515
+ error_code: data ? data.error_code : response.status,
516
+ error_message: data ? data.error_message : "401 Authorization Required"
517
+ };
518
+ }
519
+ }
520
+ catch (error) {
521
+ success = true;
522
+ return {
523
+ data: null,
524
+ error: true,
525
+ error_code: data ? data.error_code : response.status,
526
+ error_message: data ? data.error_message : "401 Authorization Required"
527
+ };
528
+ }
529
+ }
530
+ }
531
+ /**
532
+ *
533
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
534
+ * @param {string} dexName - The DEX name eg: `uniswap`.
535
+ *
536
+ */
537
+ async getNetworkExchangeTokens(chainName, dexName) {
538
+ let success = false;
539
+ let data;
540
+ let response;
541
+ const backoff = new backoff_1.ExponentialBackoff();
542
+ while (!success) {
543
+ try {
544
+ const urlParams = new URLSearchParams();
545
+ response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/?${urlParams}`, {
546
+ headers: {
547
+ "Authorization": `Bearer ${this.apiKey}`
548
+ }
549
+ });
550
+ data = await response.json();
551
+ if (data.error && data.error_code === 429) {
552
+ try {
553
+ await backoff.backOff();
554
+ }
555
+ catch (error) {
556
+ (0, ApiHelpers_1.checkAndModifyResponse)(data);
557
+ success = true;
558
+ return {
559
+ data: null,
560
+ error: data.error,
561
+ error_code: data ? data.error_code : response.status,
562
+ error_message: data ? data.error_message : "401 Authorization Required"
563
+ };
564
+ }
565
+ }
566
+ else {
567
+ const dataClass = new NetworkExchangeTokensResponse(data.data);
568
+ (0, ApiHelpers_1.checkAndModifyResponse)(dataClass);
569
+ success = true;
570
+ return {
571
+ data: dataClass,
572
+ error: data.error,
573
+ error_code: data ? data.error_code : response.status,
574
+ error_message: data ? data.error_message : "401 Authorization Required"
575
+ };
576
+ }
577
+ }
578
+ catch (error) {
579
+ success = true;
580
+ return {
581
+ data: null,
582
+ error: true,
583
+ error_code: data ? data.error_code : response.status,
584
+ error_message: data ? data.error_message : "401 Authorization Required"
585
+ };
586
+ }
587
+ }
588
+ }
589
+ /**
590
+ *
591
+
592
+ *
593
+ */
594
+ async getSupportedDEXes() {
595
+ let success = false;
596
+ let data;
597
+ let response;
598
+ const backoff = new backoff_1.ExponentialBackoff();
599
+ while (!success) {
600
+ try {
601
+ const urlParams = new URLSearchParams();
602
+ response = await fetch(`https://api.covalenthq.com/v1/xy=k/supported_dexes/?${urlParams}`, {
603
+ headers: {
604
+ "Authorization": `Bearer ${this.apiKey}`
605
+ }
606
+ });
607
+ data = await response.json();
608
+ if (data.error && data.error_code === 429) {
609
+ try {
610
+ await backoff.backOff();
611
+ }
612
+ catch (error) {
613
+ (0, ApiHelpers_1.checkAndModifyResponse)(data);
614
+ success = true;
615
+ return {
616
+ data: null,
617
+ error: data.error,
618
+ error_code: data ? data.error_code : response.status,
619
+ error_message: data ? data.error_message : "401 Authorization Required"
620
+ };
621
+ }
622
+ }
623
+ else {
624
+ const dataClass = new SupportedDexesResponse(data.data);
625
+ (0, ApiHelpers_1.checkAndModifyResponse)(dataClass);
626
+ success = true;
627
+ return {
628
+ data: dataClass,
629
+ error: data.error,
630
+ error_code: data ? data.error_code : response.status,
631
+ error_message: data ? data.error_message : "401 Authorization Required"
632
+ };
633
+ }
634
+ }
635
+ catch (error) {
636
+ success = true;
637
+ return {
638
+ data: null,
639
+ error: true,
640
+ error_code: data ? data.error_code : response.status,
641
+ error_message: data ? data.error_message : "401 Authorization Required"
642
+ };
643
+ }
644
+ }
645
+ }
646
+ /**
647
+ *
648
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
649
+ * @param {string} dexName - The DEX name eg: `uniswap`.
650
+ * @param {string} tokenAddress - The token contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
651
+ *
652
+ */
653
+ async getSingleNetworkExchangeToken(chainName, dexName, tokenAddress) {
654
+ let success = false;
655
+ let data;
656
+ let response;
657
+ const backoff = new backoff_1.ExponentialBackoff();
658
+ while (!success) {
659
+ try {
660
+ const urlParams = new URLSearchParams();
661
+ response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/?${urlParams}`, {
662
+ headers: {
663
+ "Authorization": `Bearer ${this.apiKey}`
664
+ }
665
+ });
666
+ data = await response.json();
667
+ if (data.error && data.error_code === 429) {
668
+ try {
669
+ await backoff.backOff();
670
+ }
671
+ catch (error) {
672
+ (0, ApiHelpers_1.checkAndModifyResponse)(data);
673
+ success = true;
674
+ return {
675
+ data: null,
676
+ error: data.error,
677
+ error_code: data ? data.error_code : response.status,
678
+ error_message: data ? data.error_message : "401 Authorization Required"
679
+ };
680
+ }
681
+ }
682
+ else {
683
+ const dataClass = new SingleNetworkExchangeTokenResponse(data.data);
684
+ (0, ApiHelpers_1.checkAndModifyResponse)(dataClass);
685
+ success = true;
686
+ return {
687
+ data: dataClass,
688
+ error: data.error,
689
+ error_code: data ? data.error_code : response.status,
690
+ error_message: data ? data.error_message : "401 Authorization Required"
691
+ };
692
+ }
693
+ }
694
+ catch (error) {
695
+ success = true;
696
+ return {
697
+ data: null,
698
+ error: true,
699
+ error_code: data ? data.error_code : response.status,
700
+ error_message: data ? data.error_message : "401 Authorization Required"
701
+ };
702
+ }
703
+ }
704
+ }
705
+ /**
706
+ *
707
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
708
+ * @param {string} dexName - The DEX name eg: `uniswap`.
709
+ * @param {string} accountAddress - The account address. Passing in an `ENS` or `RNS` resolves automatically.
710
+ *
711
+ */
712
+ async getTransactionsForAccountAddress(chainName, dexName, accountAddress) {
713
+ let success = false;
714
+ let data;
715
+ let response;
716
+ const backoff = new backoff_1.ExponentialBackoff();
717
+ while (!success) {
718
+ try {
719
+ const urlParams = new URLSearchParams();
720
+ response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/address/${accountAddress}/transactions/?${urlParams}`, {
721
+ headers: {
722
+ "Authorization": `Bearer ${this.apiKey}`
723
+ }
724
+ });
725
+ data = await response.json();
726
+ if (data.error && data.error_code === 429) {
727
+ try {
728
+ await backoff.backOff();
729
+ }
730
+ catch (error) {
731
+ (0, ApiHelpers_1.checkAndModifyResponse)(data);
732
+ success = true;
733
+ return {
734
+ data: null,
735
+ error: data.error,
736
+ error_code: data ? data.error_code : response.status,
737
+ error_message: data ? data.error_message : "401 Authorization Required"
738
+ };
739
+ }
740
+ }
741
+ else {
742
+ const dataClass = new TransactionsForAccountAddressResponse(data.data);
743
+ (0, ApiHelpers_1.checkAndModifyResponse)(dataClass);
744
+ success = true;
745
+ return {
746
+ data: dataClass,
747
+ error: data.error,
748
+ error_code: data ? data.error_code : response.status,
749
+ error_message: data ? data.error_message : "401 Authorization Required"
750
+ };
751
+ }
752
+ }
753
+ catch (error) {
754
+ success = true;
755
+ return {
756
+ data: null,
757
+ error: true,
758
+ error_code: data ? data.error_code : response.status,
759
+ error_message: data ? data.error_message : "401 Authorization Required"
760
+ };
761
+ }
762
+ }
763
+ }
764
+ /**
765
+ *
766
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
767
+ * @param {string} dexName - The DEX name eg: `uniswap`.
768
+ * @param {string} tokenAddress - The token contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
769
+ *
770
+ */
771
+ async getTransactionsForTokenAddress(chainName, dexName, tokenAddress) {
772
+ let success = false;
773
+ let data;
774
+ let response;
775
+ const backoff = new backoff_1.ExponentialBackoff();
776
+ while (!success) {
777
+ try {
778
+ const urlParams = new URLSearchParams();
779
+ response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/tokens/address/${tokenAddress}/transactions/?${urlParams}`, {
780
+ headers: {
781
+ "Authorization": `Bearer ${this.apiKey}`
782
+ }
783
+ });
784
+ data = await response.json();
785
+ if (data.error && data.error_code === 429) {
786
+ try {
787
+ await backoff.backOff();
788
+ }
789
+ catch (error) {
790
+ (0, ApiHelpers_1.checkAndModifyResponse)(data);
791
+ success = true;
792
+ return {
793
+ data: null,
794
+ error: data.error,
795
+ error_code: data ? data.error_code : response.status,
796
+ error_message: data ? data.error_message : "401 Authorization Required"
797
+ };
798
+ }
799
+ }
800
+ else {
801
+ const dataClass = new TransactionsForTokenAddressResponse(data.data);
802
+ (0, ApiHelpers_1.checkAndModifyResponse)(dataClass);
803
+ success = true;
804
+ return {
805
+ data: dataClass,
806
+ error: data.error,
807
+ error_code: data ? data.error_code : response.status,
808
+ error_message: data ? data.error_message : "401 Authorization Required"
809
+ };
810
+ }
811
+ }
812
+ catch (error) {
813
+ success = true;
814
+ return {
815
+ data: null,
816
+ error: true,
817
+ error_code: data ? data.error_code : response.status,
818
+ error_message: data ? data.error_message : "401 Authorization Required"
819
+ };
820
+ }
821
+ }
822
+ }
823
+ /**
824
+ *
825
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
826
+ * @param {string} dexName - The DEX name eg: `uniswap`.
827
+ * @param {string} poolAddress - The pool contract address. Passing in an `ENS`, `RNS`, `Lens Handle`, or an `Unstoppable Domain` resolves automatically.
828
+ *
829
+ */
830
+ async getTransactionsForExchange(chainName, dexName, poolAddress) {
831
+ let success = false;
832
+ let data;
833
+ let response;
834
+ const backoff = new backoff_1.ExponentialBackoff();
835
+ while (!success) {
836
+ try {
837
+ const urlParams = new URLSearchParams();
838
+ response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/pools/address/${poolAddress}/transactions/?${urlParams}`, {
839
+ headers: {
840
+ "Authorization": `Bearer ${this.apiKey}`
841
+ }
842
+ });
843
+ data = await response.json();
844
+ if (data.error && data.error_code === 429) {
845
+ try {
846
+ await backoff.backOff();
847
+ }
848
+ catch (error) {
849
+ (0, ApiHelpers_1.checkAndModifyResponse)(data);
850
+ success = true;
851
+ return {
852
+ data: null,
853
+ error: data.error,
854
+ error_code: data ? data.error_code : response.status,
855
+ error_message: data ? data.error_message : "401 Authorization Required"
856
+ };
857
+ }
858
+ }
859
+ else {
860
+ const dataClass = new TransactionsForExchangeResponse(data.data);
861
+ (0, ApiHelpers_1.checkAndModifyResponse)(dataClass);
862
+ success = true;
863
+ return {
864
+ data: dataClass,
865
+ error: data.error,
866
+ error_code: data ? data.error_code : response.status,
867
+ error_message: data ? data.error_message : "401 Authorization Required"
868
+ };
869
+ }
870
+ }
871
+ catch (error) {
872
+ success = true;
873
+ return {
874
+ data: null,
875
+ error: true,
876
+ error_code: data ? data.error_code : response.status,
877
+ error_message: data ? data.error_message : "401 Authorization Required"
878
+ };
879
+ }
880
+ }
881
+ }
882
+ /**
883
+ *
884
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
885
+ * @param {string} dexName - The DEX name eg: `uniswap`.
886
+ *
887
+ */
888
+ async getEcosystemChartData(chainName, dexName) {
889
+ let success = false;
890
+ let data;
891
+ let response;
892
+ const backoff = new backoff_1.ExponentialBackoff();
893
+ while (!success) {
894
+ try {
895
+ const urlParams = new URLSearchParams();
896
+ response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/ecosystem/?${urlParams}`, {
897
+ headers: {
898
+ "Authorization": `Bearer ${this.apiKey}`
899
+ }
900
+ });
901
+ data = await response.json();
902
+ if (data.error && data.error_code === 429) {
903
+ try {
904
+ await backoff.backOff();
905
+ }
906
+ catch (error) {
907
+ (0, ApiHelpers_1.checkAndModifyResponse)(data);
908
+ success = true;
909
+ return {
910
+ data: null,
911
+ error: data.error,
912
+ error_code: data ? data.error_code : response.status,
913
+ error_message: data ? data.error_message : "401 Authorization Required"
914
+ };
915
+ }
916
+ }
917
+ else {
918
+ const dataClass = new EcosystemChartDataResponse(data.data);
919
+ (0, ApiHelpers_1.checkAndModifyResponse)(dataClass);
920
+ success = true;
921
+ return {
922
+ data: dataClass,
923
+ error: data.error,
924
+ error_code: data ? data.error_code : response.status,
925
+ error_message: data ? data.error_message : "401 Authorization Required"
926
+ };
927
+ }
928
+ }
929
+ catch (error) {
930
+ success = true;
931
+ return {
932
+ data: null,
933
+ error: true,
934
+ error_code: data ? data.error_code : response.status,
935
+ error_message: data ? data.error_message : "401 Authorization Required"
936
+ };
937
+ }
938
+ }
939
+ }
940
+ /**
941
+ *
942
+ * @param {string} chainName - The chain name eg: `eth-mainnet`.
943
+ * @param {string} dexName - The DEX name eg: `uniswap`.
944
+ *
945
+ */
946
+ async getHealthData(chainName, dexName) {
947
+ let success = false;
948
+ let data;
949
+ let response;
950
+ const backoff = new backoff_1.ExponentialBackoff();
951
+ while (!success) {
952
+ try {
953
+ const urlParams = new URLSearchParams();
954
+ response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xy=k/${dexName}/health/?${urlParams}`, {
955
+ headers: {
956
+ "Authorization": `Bearer ${this.apiKey}`
957
+ }
958
+ });
959
+ data = await response.json();
960
+ if (data.error && data.error_code === 429) {
961
+ try {
962
+ await backoff.backOff();
963
+ }
964
+ catch (error) {
965
+ (0, ApiHelpers_1.checkAndModifyResponse)(data);
966
+ success = true;
967
+ return {
968
+ data: null,
969
+ error: data.error,
970
+ error_code: data ? data.error_code : response.status,
971
+ error_message: data ? data.error_message : "401 Authorization Required"
972
+ };
973
+ }
974
+ }
975
+ else {
976
+ const dataClass = new HealthDataResponse(data.data);
977
+ (0, ApiHelpers_1.checkAndModifyResponse)(dataClass);
978
+ success = true;
979
+ return {
980
+ data: dataClass,
981
+ error: data.error,
982
+ error_code: data ? data.error_code : response.status,
983
+ error_message: data ? data.error_message : "401 Authorization Required"
984
+ };
985
+ }
986
+ }
987
+ catch (error) {
988
+ success = true;
989
+ return {
990
+ data: null,
991
+ error: true,
992
+ error_code: data ? data.error_code : response.status,
993
+ error_message: data ? data.error_message : "401 Authorization Required"
994
+ };
995
+ }
996
+ }
997
+ }
998
+ }
999
+ exports.XykService = XykService;
1000
+ //# sourceMappingURL=XykService.js.map