@covalenthq/client-sdk 0.0.2 → 0.0.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.
- package/dist/ApprovalService.js +22 -33
- package/dist/ApprovalService.js.map +1 -1
- package/dist/BalancesService.js +157 -176
- package/dist/BalancesService.js.map +1 -1
- package/dist/BaseService.js +169 -192
- package/dist/BaseService.js.map +1 -1
- package/dist/LogEventService.js +40 -51
- package/dist/LogEventService.js.map +1 -1
- package/dist/NameResolverService.js +22 -33
- package/dist/NameResolverService.js.map +1 -1
- package/dist/NftService.js +292 -323
- package/dist/NftService.js.map +1 -1
- package/dist/PricingService.js +31 -42
- package/dist/PricingService.js.map +1 -1
- package/dist/TransactionsService.d.ts +1 -1
- package/dist/TransactionsService.js +286 -295
- package/dist/TransactionsService.js.map +1 -1
- package/dist/XykService.js +242 -273
- package/dist/XykService.js.map +1 -1
- package/package.json +1 -1
package/dist/XykService.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.XykService = void 0;
|
|
13
4
|
const baseDelayMs = 1000; // Base delay in milliseconds
|
|
@@ -21,35 +12,33 @@ class XykService {
|
|
|
21
12
|
* @param {string} dexName - The DEX name eg: `uniswap_v2`.
|
|
22
13
|
*
|
|
23
14
|
*/
|
|
24
|
-
getPools(chainName, dexName) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
const data = yield response.json();
|
|
37
|
-
if (data.error && data.error_code === 429) {
|
|
38
|
-
retryCount++;
|
|
39
|
-
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
40
|
-
yield new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
success = true;
|
|
44
|
-
return data;
|
|
15
|
+
async getPools(chainName, dexName) {
|
|
16
|
+
let retryCount = 0;
|
|
17
|
+
let success = false;
|
|
18
|
+
while (!success) {
|
|
19
|
+
try {
|
|
20
|
+
const urlParams = new URLSearchParams();
|
|
21
|
+
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/pools/?${urlParams}`, {
|
|
22
|
+
headers: {
|
|
23
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
45
24
|
}
|
|
25
|
+
});
|
|
26
|
+
const data = await response.json();
|
|
27
|
+
if (data.error && data.error_code === 429) {
|
|
28
|
+
retryCount++;
|
|
29
|
+
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
30
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
46
31
|
}
|
|
47
|
-
|
|
32
|
+
else {
|
|
48
33
|
success = true;
|
|
49
|
-
return
|
|
34
|
+
return data;
|
|
50
35
|
}
|
|
51
36
|
}
|
|
52
|
-
|
|
37
|
+
catch (error) {
|
|
38
|
+
success = true;
|
|
39
|
+
return error.message;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
53
42
|
}
|
|
54
43
|
/**
|
|
55
44
|
*
|
|
@@ -58,35 +47,33 @@ class XykService {
|
|
|
58
47
|
* @param {string} poolAddress - The pool contract address. Passing in an `ENS`, `RNS`, or an `Unstoppable Domain` resolves automatically.
|
|
59
48
|
*
|
|
60
49
|
*/
|
|
61
|
-
getPoolByAddress(chainName, dexName, poolAddress) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
const data = yield response.json();
|
|
74
|
-
if (data.error && data.error_code === 429) {
|
|
75
|
-
retryCount++;
|
|
76
|
-
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
77
|
-
yield new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
success = true;
|
|
81
|
-
return data;
|
|
50
|
+
async getPoolByAddress(chainName, dexName, poolAddress) {
|
|
51
|
+
let retryCount = 0;
|
|
52
|
+
let success = false;
|
|
53
|
+
while (!success) {
|
|
54
|
+
try {
|
|
55
|
+
const urlParams = new URLSearchParams();
|
|
56
|
+
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/pools/address/${poolAddress}/?${urlParams}`, {
|
|
57
|
+
headers: {
|
|
58
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
82
59
|
}
|
|
60
|
+
});
|
|
61
|
+
const data = await response.json();
|
|
62
|
+
if (data.error && data.error_code === 429) {
|
|
63
|
+
retryCount++;
|
|
64
|
+
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
65
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
83
66
|
}
|
|
84
|
-
|
|
67
|
+
else {
|
|
85
68
|
success = true;
|
|
86
|
-
return
|
|
69
|
+
return data;
|
|
87
70
|
}
|
|
88
71
|
}
|
|
89
|
-
|
|
72
|
+
catch (error) {
|
|
73
|
+
success = true;
|
|
74
|
+
return error.message;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
90
77
|
}
|
|
91
78
|
/**
|
|
92
79
|
*
|
|
@@ -95,35 +82,33 @@ class XykService {
|
|
|
95
82
|
* @param {string} accountAddress - The account address.
|
|
96
83
|
*
|
|
97
84
|
*/
|
|
98
|
-
getAddressExchangeBalances(chainName, dexName, accountAddress) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
const data = yield response.json();
|
|
111
|
-
if (data.error && data.error_code === 429) {
|
|
112
|
-
retryCount++;
|
|
113
|
-
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
114
|
-
yield new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
success = true;
|
|
118
|
-
return data;
|
|
85
|
+
async getAddressExchangeBalances(chainName, dexName, accountAddress) {
|
|
86
|
+
let retryCount = 0;
|
|
87
|
+
let success = false;
|
|
88
|
+
while (!success) {
|
|
89
|
+
try {
|
|
90
|
+
const urlParams = new URLSearchParams();
|
|
91
|
+
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/address/${accountAddress}/balances/?${urlParams}`, {
|
|
92
|
+
headers: {
|
|
93
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
119
94
|
}
|
|
95
|
+
});
|
|
96
|
+
const data = await response.json();
|
|
97
|
+
if (data.error && data.error_code === 429) {
|
|
98
|
+
retryCount++;
|
|
99
|
+
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
100
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
120
101
|
}
|
|
121
|
-
|
|
102
|
+
else {
|
|
122
103
|
success = true;
|
|
123
|
-
return
|
|
104
|
+
return data;
|
|
124
105
|
}
|
|
125
106
|
}
|
|
126
|
-
|
|
107
|
+
catch (error) {
|
|
108
|
+
success = true;
|
|
109
|
+
return error.message;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
127
112
|
}
|
|
128
113
|
/**
|
|
129
114
|
*
|
|
@@ -131,70 +116,66 @@ class XykService {
|
|
|
131
116
|
* @param {string} dexName - The DEX name eg: `uniswap`.
|
|
132
117
|
*
|
|
133
118
|
*/
|
|
134
|
-
getNetworkExchangeTokens(chainName, dexName) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
const data = yield response.json();
|
|
147
|
-
if (data.error && data.error_code === 429) {
|
|
148
|
-
retryCount++;
|
|
149
|
-
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
150
|
-
yield new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
success = true;
|
|
154
|
-
return data;
|
|
119
|
+
async getNetworkExchangeTokens(chainName, dexName) {
|
|
120
|
+
let retryCount = 0;
|
|
121
|
+
let success = false;
|
|
122
|
+
while (!success) {
|
|
123
|
+
try {
|
|
124
|
+
const urlParams = new URLSearchParams();
|
|
125
|
+
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/tokens/?${urlParams}`, {
|
|
126
|
+
headers: {
|
|
127
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
155
128
|
}
|
|
129
|
+
});
|
|
130
|
+
const data = await response.json();
|
|
131
|
+
if (data.error && data.error_code === 429) {
|
|
132
|
+
retryCount++;
|
|
133
|
+
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
134
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
156
135
|
}
|
|
157
|
-
|
|
136
|
+
else {
|
|
158
137
|
success = true;
|
|
159
|
-
return
|
|
138
|
+
return data;
|
|
160
139
|
}
|
|
161
140
|
}
|
|
162
|
-
|
|
141
|
+
catch (error) {
|
|
142
|
+
success = true;
|
|
143
|
+
return error.message;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
163
146
|
}
|
|
164
147
|
/**
|
|
165
148
|
*
|
|
166
149
|
|
|
167
150
|
*
|
|
168
151
|
*/
|
|
169
|
-
getSupportedDEXes() {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
const data = yield response.json();
|
|
182
|
-
if (data.error && data.error_code === 429) {
|
|
183
|
-
retryCount++;
|
|
184
|
-
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
185
|
-
yield new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
success = true;
|
|
189
|
-
return data;
|
|
152
|
+
async getSupportedDEXes() {
|
|
153
|
+
let retryCount = 0;
|
|
154
|
+
let success = false;
|
|
155
|
+
while (!success) {
|
|
156
|
+
try {
|
|
157
|
+
const urlParams = new URLSearchParams();
|
|
158
|
+
const response = await fetch(`https://api.covalenthq.com/v1/xyk/supported_dexes/?${urlParams}`, {
|
|
159
|
+
headers: {
|
|
160
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
190
161
|
}
|
|
162
|
+
});
|
|
163
|
+
const data = await response.json();
|
|
164
|
+
if (data.error && data.error_code === 429) {
|
|
165
|
+
retryCount++;
|
|
166
|
+
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
167
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
191
168
|
}
|
|
192
|
-
|
|
169
|
+
else {
|
|
193
170
|
success = true;
|
|
194
|
-
return
|
|
171
|
+
return data;
|
|
195
172
|
}
|
|
196
173
|
}
|
|
197
|
-
|
|
174
|
+
catch (error) {
|
|
175
|
+
success = true;
|
|
176
|
+
return error.message;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
198
179
|
}
|
|
199
180
|
/**
|
|
200
181
|
*
|
|
@@ -203,35 +184,33 @@ class XykService {
|
|
|
203
184
|
* @param {string} tokenAddress - The token contract address. Passing in an `ENS`, `RNS`, or an `Unstoppable Domain` resolves automatically.
|
|
204
185
|
*
|
|
205
186
|
*/
|
|
206
|
-
getSingleNetworkExchangeToken(chainName, dexName, tokenAddress) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
const data = yield response.json();
|
|
219
|
-
if (data.error && data.error_code === 429) {
|
|
220
|
-
retryCount++;
|
|
221
|
-
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
222
|
-
yield new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
success = true;
|
|
226
|
-
return data;
|
|
187
|
+
async getSingleNetworkExchangeToken(chainName, dexName, tokenAddress) {
|
|
188
|
+
let retryCount = 0;
|
|
189
|
+
let success = false;
|
|
190
|
+
while (!success) {
|
|
191
|
+
try {
|
|
192
|
+
const urlParams = new URLSearchParams();
|
|
193
|
+
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/tokens/address/${tokenAddress}/?${urlParams}`, {
|
|
194
|
+
headers: {
|
|
195
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
227
196
|
}
|
|
197
|
+
});
|
|
198
|
+
const data = await response.json();
|
|
199
|
+
if (data.error && data.error_code === 429) {
|
|
200
|
+
retryCount++;
|
|
201
|
+
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
202
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
228
203
|
}
|
|
229
|
-
|
|
204
|
+
else {
|
|
230
205
|
success = true;
|
|
231
|
-
return
|
|
206
|
+
return data;
|
|
232
207
|
}
|
|
233
208
|
}
|
|
234
|
-
|
|
209
|
+
catch (error) {
|
|
210
|
+
success = true;
|
|
211
|
+
return error.message;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
235
214
|
}
|
|
236
215
|
/**
|
|
237
216
|
*
|
|
@@ -240,35 +219,33 @@ class XykService {
|
|
|
240
219
|
* @param {string} accountAddress - The account address. Passing in an `ENS` or `RNS` resolves automatically.
|
|
241
220
|
*
|
|
242
221
|
*/
|
|
243
|
-
getTransactionsForAccountAddress(chainName, dexName, accountAddress) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
const data = yield response.json();
|
|
256
|
-
if (data.error && data.error_code === 429) {
|
|
257
|
-
retryCount++;
|
|
258
|
-
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
259
|
-
yield new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
success = true;
|
|
263
|
-
return data;
|
|
222
|
+
async getTransactionsForAccountAddress(chainName, dexName, accountAddress) {
|
|
223
|
+
let retryCount = 0;
|
|
224
|
+
let success = false;
|
|
225
|
+
while (!success) {
|
|
226
|
+
try {
|
|
227
|
+
const urlParams = new URLSearchParams();
|
|
228
|
+
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/address/${accountAddress}/transactions/?${urlParams}`, {
|
|
229
|
+
headers: {
|
|
230
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
264
231
|
}
|
|
232
|
+
});
|
|
233
|
+
const data = await response.json();
|
|
234
|
+
if (data.error && data.error_code === 429) {
|
|
235
|
+
retryCount++;
|
|
236
|
+
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
237
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
265
238
|
}
|
|
266
|
-
|
|
239
|
+
else {
|
|
267
240
|
success = true;
|
|
268
|
-
return
|
|
241
|
+
return data;
|
|
269
242
|
}
|
|
270
243
|
}
|
|
271
|
-
|
|
244
|
+
catch (error) {
|
|
245
|
+
success = true;
|
|
246
|
+
return error.message;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
272
249
|
}
|
|
273
250
|
/**
|
|
274
251
|
*
|
|
@@ -277,35 +254,33 @@ class XykService {
|
|
|
277
254
|
* @param {string} tokenAddress - The token contract address. Passing in an `ENS`, `RNS`, or an `Unstoppable Domain` resolves automatically.
|
|
278
255
|
*
|
|
279
256
|
*/
|
|
280
|
-
getTransactionsForTokenAddress(chainName, dexName, tokenAddress) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
const data = yield response.json();
|
|
293
|
-
if (data.error && data.error_code === 429) {
|
|
294
|
-
retryCount++;
|
|
295
|
-
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
296
|
-
yield new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
success = true;
|
|
300
|
-
return data;
|
|
257
|
+
async getTransactionsForTokenAddress(chainName, dexName, tokenAddress) {
|
|
258
|
+
let retryCount = 0;
|
|
259
|
+
let success = false;
|
|
260
|
+
while (!success) {
|
|
261
|
+
try {
|
|
262
|
+
const urlParams = new URLSearchParams();
|
|
263
|
+
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/tokens/address/${tokenAddress}/transactions/?${urlParams}`, {
|
|
264
|
+
headers: {
|
|
265
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
301
266
|
}
|
|
267
|
+
});
|
|
268
|
+
const data = await response.json();
|
|
269
|
+
if (data.error && data.error_code === 429) {
|
|
270
|
+
retryCount++;
|
|
271
|
+
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
272
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
302
273
|
}
|
|
303
|
-
|
|
274
|
+
else {
|
|
304
275
|
success = true;
|
|
305
|
-
return
|
|
276
|
+
return data;
|
|
306
277
|
}
|
|
307
278
|
}
|
|
308
|
-
|
|
279
|
+
catch (error) {
|
|
280
|
+
success = true;
|
|
281
|
+
return error.message;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
309
284
|
}
|
|
310
285
|
/**
|
|
311
286
|
*
|
|
@@ -314,35 +289,33 @@ class XykService {
|
|
|
314
289
|
* @param {string} poolAddress - The pool contract address. Passing in an `ENS`, `RNS`, or an `Unstoppable Domain` resolves automatically.
|
|
315
290
|
*
|
|
316
291
|
*/
|
|
317
|
-
getTransactionsForExchange(chainName, dexName, poolAddress) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
const data = yield response.json();
|
|
330
|
-
if (data.error && data.error_code === 429) {
|
|
331
|
-
retryCount++;
|
|
332
|
-
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
333
|
-
yield new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
success = true;
|
|
337
|
-
return data;
|
|
292
|
+
async getTransactionsForExchange(chainName, dexName, poolAddress) {
|
|
293
|
+
let retryCount = 0;
|
|
294
|
+
let success = false;
|
|
295
|
+
while (!success) {
|
|
296
|
+
try {
|
|
297
|
+
const urlParams = new URLSearchParams();
|
|
298
|
+
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/pools/address/${poolAddress}/transactions/?${urlParams}`, {
|
|
299
|
+
headers: {
|
|
300
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
338
301
|
}
|
|
302
|
+
});
|
|
303
|
+
const data = await response.json();
|
|
304
|
+
if (data.error && data.error_code === 429) {
|
|
305
|
+
retryCount++;
|
|
306
|
+
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
307
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
339
308
|
}
|
|
340
|
-
|
|
309
|
+
else {
|
|
341
310
|
success = true;
|
|
342
|
-
return
|
|
311
|
+
return data;
|
|
343
312
|
}
|
|
344
313
|
}
|
|
345
|
-
|
|
314
|
+
catch (error) {
|
|
315
|
+
success = true;
|
|
316
|
+
return error.message;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
346
319
|
}
|
|
347
320
|
/**
|
|
348
321
|
*
|
|
@@ -350,35 +323,33 @@ class XykService {
|
|
|
350
323
|
* @param {string} dexName - The DEX name eg: `uniswap`.
|
|
351
324
|
*
|
|
352
325
|
*/
|
|
353
|
-
getEcosystemChartData(chainName, dexName) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
const data = yield response.json();
|
|
366
|
-
if (data.error && data.error_code === 429) {
|
|
367
|
-
retryCount++;
|
|
368
|
-
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
369
|
-
yield new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
success = true;
|
|
373
|
-
return data;
|
|
326
|
+
async getEcosystemChartData(chainName, dexName) {
|
|
327
|
+
let retryCount = 0;
|
|
328
|
+
let success = false;
|
|
329
|
+
while (!success) {
|
|
330
|
+
try {
|
|
331
|
+
const urlParams = new URLSearchParams();
|
|
332
|
+
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/ecosystem/?${urlParams}`, {
|
|
333
|
+
headers: {
|
|
334
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
374
335
|
}
|
|
336
|
+
});
|
|
337
|
+
const data = await response.json();
|
|
338
|
+
if (data.error && data.error_code === 429) {
|
|
339
|
+
retryCount++;
|
|
340
|
+
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
341
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
375
342
|
}
|
|
376
|
-
|
|
343
|
+
else {
|
|
377
344
|
success = true;
|
|
378
|
-
return
|
|
345
|
+
return data;
|
|
379
346
|
}
|
|
380
347
|
}
|
|
381
|
-
|
|
348
|
+
catch (error) {
|
|
349
|
+
success = true;
|
|
350
|
+
return error.message;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
382
353
|
}
|
|
383
354
|
/**
|
|
384
355
|
*
|
|
@@ -386,35 +357,33 @@ class XykService {
|
|
|
386
357
|
* @param {string} dexName - The DEX name eg: `uniswap`.
|
|
387
358
|
*
|
|
388
359
|
*/
|
|
389
|
-
getHealthData(chainName, dexName) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
"Authorization": `Bearer ${this.apiKey}`
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
const data = yield response.json();
|
|
402
|
-
if (data.error && data.error_code === 429) {
|
|
403
|
-
retryCount++;
|
|
404
|
-
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
405
|
-
yield new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
success = true;
|
|
409
|
-
return data;
|
|
360
|
+
async getHealthData(chainName, dexName) {
|
|
361
|
+
let retryCount = 0;
|
|
362
|
+
let success = false;
|
|
363
|
+
while (!success) {
|
|
364
|
+
try {
|
|
365
|
+
const urlParams = new URLSearchParams();
|
|
366
|
+
const response = await fetch(`https://api.covalenthq.com/v1/${chainName}/xyk/${dexName}/health/?${urlParams}`, {
|
|
367
|
+
headers: {
|
|
368
|
+
"Authorization": `Bearer ${this.apiKey}`
|
|
410
369
|
}
|
|
370
|
+
});
|
|
371
|
+
const data = await response.json();
|
|
372
|
+
if (data.error && data.error_code === 429) {
|
|
373
|
+
retryCount++;
|
|
374
|
+
const delayMs = Math.pow(2, retryCount) * baseDelayMs; // Exponential delay calculation
|
|
375
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
411
376
|
}
|
|
412
|
-
|
|
377
|
+
else {
|
|
413
378
|
success = true;
|
|
414
|
-
return
|
|
379
|
+
return data;
|
|
415
380
|
}
|
|
416
381
|
}
|
|
417
|
-
|
|
382
|
+
catch (error) {
|
|
383
|
+
success = true;
|
|
384
|
+
return error.message;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
418
387
|
}
|
|
419
388
|
}
|
|
420
389
|
exports.XykService = XykService;
|