@metamask-previews/core-backend 5.1.1-preview-e7b1aa6 → 5.1.1-preview-27e39dd44
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/CHANGELOG.md +0 -23
- package/README.md +55 -60
- package/dist/api/accounts/client.cjs +163 -358
- package/dist/api/accounts/client.cjs.map +1 -1
- package/dist/api/accounts/client.d.cts +12 -198
- package/dist/api/accounts/client.d.cts.map +1 -1
- package/dist/api/accounts/client.d.mts +12 -198
- package/dist/api/accounts/client.d.mts.map +1 -1
- package/dist/api/accounts/client.mjs +164 -359
- package/dist/api/accounts/client.mjs.map +1 -1
- package/dist/api/index.cjs +1 -2
- package/dist/api/index.cjs.map +1 -1
- package/dist/api/index.d.cts +1 -1
- package/dist/api/index.d.cts.map +1 -1
- package/dist/api/index.d.mts +1 -1
- package/dist/api/index.d.mts.map +1 -1
- package/dist/api/index.mjs +1 -1
- package/dist/api/index.mjs.map +1 -1
- package/dist/api/prices/client.cjs +140 -398
- package/dist/api/prices/client.cjs.map +1 -1
- package/dist/api/prices/client.d.cts +3 -215
- package/dist/api/prices/client.d.cts.map +1 -1
- package/dist/api/prices/client.d.mts +3 -215
- package/dist/api/prices/client.d.mts.map +1 -1
- package/dist/api/prices/client.mjs +140 -398
- package/dist/api/prices/client.mjs.map +1 -1
- package/dist/api/shared-types.cjs +1 -18
- package/dist/api/shared-types.cjs.map +1 -1
- package/dist/api/shared-types.d.cts +3 -23
- package/dist/api/shared-types.d.cts.map +1 -1
- package/dist/api/shared-types.d.mts +3 -23
- package/dist/api/shared-types.d.mts.map +1 -1
- package/dist/api/shared-types.mjs +0 -16
- package/dist/api/shared-types.mjs.map +1 -1
- package/dist/api/token/client.cjs +77 -232
- package/dist/api/token/client.cjs.map +1 -1
- package/dist/api/token/client.d.cts +0 -165
- package/dist/api/token/client.d.cts.map +1 -1
- package/dist/api/token/client.d.mts +0 -165
- package/dist/api/token/client.d.mts.map +1 -1
- package/dist/api/token/client.mjs +77 -232
- package/dist/api/token/client.mjs.map +1 -1
- package/dist/api/tokens/client.cjs +23 -64
- package/dist/api/tokens/client.cjs.map +1 -1
- package/dist/api/tokens/client.d.cts +0 -24
- package/dist/api/tokens/client.d.cts.map +1 -1
- package/dist/api/tokens/client.d.mts +0 -24
- package/dist/api/tokens/client.d.mts.map +1 -1
- package/dist/api/tokens/client.mjs +23 -64
- package/dist/api/tokens/client.mjs.map +1 -1
- package/dist/index.cjs +1 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/dist/ApiPlatformClientService-method-action-types.cjs +0 -7
- package/dist/ApiPlatformClientService-method-action-types.cjs.map +0 -1
- package/dist/ApiPlatformClientService-method-action-types.d.cts +0 -21
- package/dist/ApiPlatformClientService-method-action-types.d.cts.map +0 -1
- package/dist/ApiPlatformClientService-method-action-types.d.mts +0 -21
- package/dist/ApiPlatformClientService-method-action-types.d.mts.map +0 -1
- package/dist/ApiPlatformClientService-method-action-types.mjs +0 -6
- package/dist/ApiPlatformClientService-method-action-types.mjs.map +0 -1
- package/dist/ApiPlatformClientService.cjs +0 -82
- package/dist/ApiPlatformClientService.cjs.map +0 -1
- package/dist/ApiPlatformClientService.d.cts +0 -86
- package/dist/ApiPlatformClientService.d.cts.map +0 -1
- package/dist/ApiPlatformClientService.d.mts +0 -86
- package/dist/ApiPlatformClientService.d.mts.map +0 -1
- package/dist/ApiPlatformClientService.mjs +0 -78
- package/dist/ApiPlatformClientService.mjs.map +0 -1
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.PricesApiClient = void 0;
|
|
14
14
|
const base_client_1 = require("../base-client.cjs");
|
|
15
|
-
const shared_types_1 = require("../shared-types.cjs");
|
|
16
15
|
/**
|
|
17
16
|
* Prices API Client.
|
|
18
17
|
* Provides methods for interacting with the Price API.
|
|
@@ -33,80 +32,36 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
33
32
|
// SUPPORTED NETWORKS
|
|
34
33
|
// ==========================================================================
|
|
35
34
|
/**
|
|
36
|
-
*
|
|
35
|
+
* Get price supported networks (v1 endpoint).
|
|
37
36
|
*
|
|
38
37
|
* @param options - Fetch options including cache settings.
|
|
39
|
-
* @returns
|
|
38
|
+
* @returns The supported networks response.
|
|
40
39
|
*/
|
|
41
|
-
|
|
42
|
-
return {
|
|
40
|
+
async fetchPriceV1SupportedNetworks(options) {
|
|
41
|
+
return this.queryClient.fetchQuery({
|
|
43
42
|
queryKey: ['prices', 'v1SupportedNetworks'],
|
|
44
43
|
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/supportedNetworks', { signal }),
|
|
45
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
46
44
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.SUPPORTED_NETWORKS,
|
|
47
45
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.EXTENDED,
|
|
48
|
-
};
|
|
46
|
+
});
|
|
49
47
|
}
|
|
50
48
|
/**
|
|
51
|
-
* Get price supported networks (
|
|
49
|
+
* Get price supported networks in CAIP format (v2 endpoint).
|
|
52
50
|
*
|
|
53
51
|
* @param options - Fetch options including cache settings.
|
|
54
52
|
* @returns The supported networks response.
|
|
55
53
|
*/
|
|
56
|
-
async
|
|
57
|
-
return this.queryClient.fetchQuery(
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Returns the TanStack Query options object for price v2 supported networks.
|
|
61
|
-
*
|
|
62
|
-
* @param options - Fetch options including cache settings.
|
|
63
|
-
* @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
|
|
64
|
-
*/
|
|
65
|
-
getPriceV2SupportedNetworksQueryOptions(options) {
|
|
66
|
-
return {
|
|
54
|
+
async fetchPriceV2SupportedNetworks(options) {
|
|
55
|
+
return this.queryClient.fetchQuery({
|
|
67
56
|
queryKey: ['prices', 'v2SupportedNetworks'],
|
|
68
57
|
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v2/supportedNetworks', { signal }),
|
|
69
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
70
58
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.SUPPORTED_NETWORKS,
|
|
71
59
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.EXTENDED,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Get price supported networks in CAIP format (v2 endpoint).
|
|
76
|
-
*
|
|
77
|
-
* @param options - Fetch options including cache settings.
|
|
78
|
-
* @returns The supported networks response.
|
|
79
|
-
*/
|
|
80
|
-
async fetchPriceV2SupportedNetworks(options) {
|
|
81
|
-
return this.queryClient.fetchQuery(this.getPriceV2SupportedNetworksQueryOptions(options));
|
|
60
|
+
});
|
|
82
61
|
}
|
|
83
62
|
// ==========================================================================
|
|
84
63
|
// EXCHANGE RATES
|
|
85
64
|
// ==========================================================================
|
|
86
|
-
/**
|
|
87
|
-
* Returns the TanStack Query options object for v1 exchange rates.
|
|
88
|
-
*
|
|
89
|
-
* @param baseCurrency - The base currency code.
|
|
90
|
-
* @param options - Fetch options including cache settings.
|
|
91
|
-
* @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
|
|
92
|
-
*/
|
|
93
|
-
getV1ExchangeRatesQueryOptions(baseCurrency, options) {
|
|
94
|
-
return {
|
|
95
|
-
queryKey: ['prices', 'v1ExchangeRates', baseCurrency],
|
|
96
|
-
queryFn: async ({ signal, }) => {
|
|
97
|
-
if (baseCurrency === '') {
|
|
98
|
-
return {};
|
|
99
|
-
}
|
|
100
|
-
return this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates', {
|
|
101
|
-
signal,
|
|
102
|
-
params: { baseCurrency },
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
106
|
-
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.EXCHANGE_RATES,
|
|
107
|
-
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
65
|
/**
|
|
111
66
|
* Get all exchange rates for a base currency (v1 endpoint).
|
|
112
67
|
*
|
|
@@ -115,25 +70,15 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
115
70
|
* @returns The exchange rates response.
|
|
116
71
|
*/
|
|
117
72
|
async fetchV1ExchangeRates(baseCurrency, options) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
* Returns the TanStack Query options object for v1 fiat exchange rates.
|
|
125
|
-
*
|
|
126
|
-
* @param options - Fetch options including cache settings.
|
|
127
|
-
* @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
|
|
128
|
-
*/
|
|
129
|
-
getV1FiatExchangeRatesQueryOptions(options) {
|
|
130
|
-
return {
|
|
131
|
-
queryKey: ['prices', 'v1FiatExchangeRates'],
|
|
132
|
-
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates/fiat', { signal }),
|
|
133
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
73
|
+
return this.queryClient.fetchQuery({
|
|
74
|
+
queryKey: ['prices', 'v1ExchangeRates', baseCurrency],
|
|
75
|
+
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates', {
|
|
76
|
+
signal,
|
|
77
|
+
params: { baseCurrency },
|
|
78
|
+
}),
|
|
134
79
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.EXCHANGE_RATES,
|
|
135
80
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
136
|
-
};
|
|
81
|
+
});
|
|
137
82
|
}
|
|
138
83
|
/**
|
|
139
84
|
* Get fiat exchange rates (v1 endpoint).
|
|
@@ -142,22 +87,12 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
142
87
|
* @returns The exchange rates response.
|
|
143
88
|
*/
|
|
144
89
|
async fetchV1FiatExchangeRates(options) {
|
|
145
|
-
return this.queryClient.fetchQuery(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
* Returns the TanStack Query options object for v1 crypto exchange rates.
|
|
149
|
-
*
|
|
150
|
-
* @param options - Fetch options including cache settings.
|
|
151
|
-
* @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
|
|
152
|
-
*/
|
|
153
|
-
getV1CryptoExchangeRatesQueryOptions(options) {
|
|
154
|
-
return {
|
|
155
|
-
queryKey: ['prices', 'v1CryptoExchangeRates'],
|
|
156
|
-
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates/crypto', { signal }),
|
|
157
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
90
|
+
return this.queryClient.fetchQuery({
|
|
91
|
+
queryKey: ['prices', 'v1FiatExchangeRates'],
|
|
92
|
+
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates/fiat', { signal }),
|
|
158
93
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.EXCHANGE_RATES,
|
|
159
94
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
160
|
-
};
|
|
95
|
+
});
|
|
161
96
|
}
|
|
162
97
|
/**
|
|
163
98
|
* Get crypto exchange rates (v1 endpoint).
|
|
@@ -166,39 +101,16 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
166
101
|
* @returns The exchange rates response.
|
|
167
102
|
*/
|
|
168
103
|
async fetchV1CryptoExchangeRates(options) {
|
|
169
|
-
return this.queryClient.fetchQuery(
|
|
104
|
+
return this.queryClient.fetchQuery({
|
|
105
|
+
queryKey: ['prices', 'v1CryptoExchangeRates'],
|
|
106
|
+
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/exchange-rates/crypto', { signal }),
|
|
107
|
+
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.EXCHANGE_RATES,
|
|
108
|
+
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
109
|
+
});
|
|
170
110
|
}
|
|
171
111
|
// ==========================================================================
|
|
172
112
|
// V1 SPOT PRICES (CoinGecko ID based)
|
|
173
113
|
// ==========================================================================
|
|
174
|
-
/**
|
|
175
|
-
* Returns the TanStack Query options object for v1 spot prices by coin IDs.
|
|
176
|
-
*
|
|
177
|
-
* @param coinIds - Array of CoinGecko coin IDs.
|
|
178
|
-
* @param options - Fetch options including cache settings.
|
|
179
|
-
* @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
|
|
180
|
-
*/
|
|
181
|
-
getV1SpotPricesByCoinIdsQueryOptions(coinIds, options) {
|
|
182
|
-
return {
|
|
183
|
-
queryKey: [
|
|
184
|
-
'prices',
|
|
185
|
-
'v1SpotPricesByCoinIds',
|
|
186
|
-
{ coinIds: [...coinIds].sort() },
|
|
187
|
-
],
|
|
188
|
-
queryFn: async ({ signal, }) => {
|
|
189
|
-
if (coinIds.length === 0) {
|
|
190
|
-
return {};
|
|
191
|
-
}
|
|
192
|
-
return this.fetch(base_client_1.API_URLS.PRICES, '/v1/spot-prices', {
|
|
193
|
-
signal,
|
|
194
|
-
params: { coinIds },
|
|
195
|
-
});
|
|
196
|
-
},
|
|
197
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
198
|
-
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
199
|
-
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
114
|
/**
|
|
203
115
|
* Get spot prices by CoinGecko coin IDs (v1 endpoint).
|
|
204
116
|
*
|
|
@@ -210,32 +122,19 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
210
122
|
if (coinIds.length === 0) {
|
|
211
123
|
return {};
|
|
212
124
|
}
|
|
213
|
-
return this.queryClient.fetchQuery(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
getV1SpotPriceByCoinIdQueryOptions(coinId, currency = 'usd', options) {
|
|
224
|
-
return {
|
|
225
|
-
queryKey: ['prices', 'v1SpotPriceByCoinId', coinId, currency],
|
|
226
|
-
queryFn: async ({ signal, }) => {
|
|
227
|
-
if (coinId === '') {
|
|
228
|
-
return { id: '', price: 0 };
|
|
229
|
-
}
|
|
230
|
-
return this.fetch(base_client_1.API_URLS.PRICES, `/v1/spot-prices/${coinId}`, {
|
|
231
|
-
signal,
|
|
232
|
-
params: { vsCurrency: currency },
|
|
233
|
-
});
|
|
234
|
-
},
|
|
235
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
125
|
+
return this.queryClient.fetchQuery({
|
|
126
|
+
queryKey: [
|
|
127
|
+
'prices',
|
|
128
|
+
'v1SpotPricesByCoinIds',
|
|
129
|
+
{ coinIds: [...coinIds].sort() },
|
|
130
|
+
],
|
|
131
|
+
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v1/spot-prices', {
|
|
132
|
+
signal,
|
|
133
|
+
params: { coinIds },
|
|
134
|
+
}),
|
|
236
135
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
237
136
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
238
|
-
};
|
|
137
|
+
});
|
|
239
138
|
}
|
|
240
139
|
/**
|
|
241
140
|
* Get spot price for a single CoinGecko coin ID (v1 endpoint).
|
|
@@ -246,13 +145,21 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
246
145
|
* @returns The spot price data.
|
|
247
146
|
*/
|
|
248
147
|
async fetchV1SpotPriceByCoinId(coinId, currency = 'usd', options) {
|
|
249
|
-
return this.queryClient.fetchQuery(
|
|
148
|
+
return this.queryClient.fetchQuery({
|
|
149
|
+
queryKey: ['prices', 'v1SpotPriceByCoinId', coinId, currency],
|
|
150
|
+
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v1/spot-prices/${coinId}`, {
|
|
151
|
+
signal,
|
|
152
|
+
params: { vsCurrency: currency },
|
|
153
|
+
}),
|
|
154
|
+
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
155
|
+
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
156
|
+
});
|
|
250
157
|
}
|
|
251
158
|
// ==========================================================================
|
|
252
159
|
// V1 SPOT PRICES (Token Address based)
|
|
253
160
|
// ==========================================================================
|
|
254
161
|
/**
|
|
255
|
-
*
|
|
162
|
+
* Get spot prices for tokens on a chain (v1 endpoint).
|
|
256
163
|
*
|
|
257
164
|
* @param chainId - The chain ID (hex format).
|
|
258
165
|
* @param tokenAddresses - Array of token addresses.
|
|
@@ -260,12 +167,15 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
260
167
|
* @param queryOptions.currency - The currency for prices.
|
|
261
168
|
* @param queryOptions.includeMarketData - Whether to include market data.
|
|
262
169
|
* @param options - Fetch options including cache settings.
|
|
263
|
-
* @returns
|
|
170
|
+
* @returns The token prices by address.
|
|
264
171
|
*/
|
|
265
|
-
|
|
172
|
+
async fetchV1TokenPrices(chainId, tokenAddresses, queryOptions, options) {
|
|
173
|
+
if (tokenAddresses.length === 0) {
|
|
174
|
+
return {};
|
|
175
|
+
}
|
|
266
176
|
const chainIdDecimal = parseInt(chainId, 16);
|
|
267
177
|
const currency = queryOptions?.currency ?? 'usd';
|
|
268
|
-
return {
|
|
178
|
+
return this.queryClient.fetchQuery({
|
|
269
179
|
queryKey: [
|
|
270
180
|
'prices',
|
|
271
181
|
'v1TokenPrices',
|
|
@@ -276,82 +186,49 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
276
186
|
includeMarketData: queryOptions?.includeMarketData,
|
|
277
187
|
},
|
|
278
188
|
],
|
|
279
|
-
queryFn:
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
vsCurrency: currency,
|
|
288
|
-
includeMarketData: queryOptions?.includeMarketData,
|
|
289
|
-
},
|
|
290
|
-
});
|
|
291
|
-
},
|
|
292
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
189
|
+
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/spot-prices`, {
|
|
190
|
+
signal,
|
|
191
|
+
params: {
|
|
192
|
+
tokenAddresses,
|
|
193
|
+
vsCurrency: currency,
|
|
194
|
+
includeMarketData: queryOptions?.includeMarketData,
|
|
195
|
+
},
|
|
196
|
+
}),
|
|
293
197
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
294
198
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Get spot prices for tokens on a chain (v1 endpoint).
|
|
299
|
-
*
|
|
300
|
-
* @param chainId - The chain ID (hex format).
|
|
301
|
-
* @param tokenAddresses - Array of token addresses.
|
|
302
|
-
* @param queryOptions - Query options.
|
|
303
|
-
* @param queryOptions.currency - The currency for prices.
|
|
304
|
-
* @param queryOptions.includeMarketData - Whether to include market data.
|
|
305
|
-
* @param options - Fetch options including cache settings.
|
|
306
|
-
* @returns The token prices by address.
|
|
307
|
-
*/
|
|
308
|
-
async fetchV1TokenPrices(chainId, tokenAddresses, queryOptions, options) {
|
|
309
|
-
if (chainId === '' || tokenAddresses.length === 0) {
|
|
310
|
-
return {};
|
|
311
|
-
}
|
|
312
|
-
return this.queryClient.fetchQuery(this.getV1TokenPricesQueryOptions(chainId, tokenAddresses, queryOptions, options));
|
|
199
|
+
});
|
|
313
200
|
}
|
|
314
201
|
/**
|
|
315
|
-
*
|
|
202
|
+
* Get spot price for a single token (v1 endpoint).
|
|
316
203
|
*
|
|
317
204
|
* @param chainId - The chain ID (hex format).
|
|
318
205
|
* @param tokenAddress - The token address.
|
|
319
206
|
* @param currency - The currency for prices.
|
|
320
207
|
* @param options - Fetch options including cache settings.
|
|
321
|
-
* @returns
|
|
208
|
+
* @returns The market data or undefined.
|
|
322
209
|
*/
|
|
323
|
-
|
|
210
|
+
async fetchV1TokenPrice(chainId, tokenAddress, currency = 'usd', options) {
|
|
324
211
|
const chainIdDecimal = parseInt(chainId, 16);
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
212
|
+
try {
|
|
213
|
+
return await this.queryClient.fetchQuery({
|
|
214
|
+
queryKey: ['prices', 'v1TokenPrice', chainId, tokenAddress, currency],
|
|
215
|
+
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/spot-prices/${tokenAddress}`, {
|
|
329
216
|
signal,
|
|
330
217
|
params: { vsCurrency: currency },
|
|
331
|
-
})
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
* Get spot price for a single token (v1 endpoint).
|
|
340
|
-
*
|
|
341
|
-
* @param chainId - The chain ID (hex format).
|
|
342
|
-
* @param tokenAddress - The token address.
|
|
343
|
-
* @param currency - The currency for prices.
|
|
344
|
-
* @param options - Fetch options including cache settings.
|
|
345
|
-
* @returns The market data.
|
|
346
|
-
*/
|
|
347
|
-
async fetchV1TokenPrice(chainId, tokenAddress, currency = 'usd', options) {
|
|
348
|
-
return this.queryClient.fetchQuery(this.getV1TokenPriceQueryOptions(chainId, tokenAddress, currency, options));
|
|
218
|
+
}),
|
|
219
|
+
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
220
|
+
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
349
226
|
}
|
|
350
227
|
// ==========================================================================
|
|
351
228
|
// V2 SPOT PRICES
|
|
352
229
|
// ==========================================================================
|
|
353
230
|
/**
|
|
354
|
-
*
|
|
231
|
+
* Get spot prices for tokens on a chain with market data (v2 endpoint).
|
|
355
232
|
*
|
|
356
233
|
* @param chainId - The chain ID (hex format).
|
|
357
234
|
* @param tokenAddresses - Array of token addresses.
|
|
@@ -359,13 +236,16 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
359
236
|
* @param queryOptions.currency - The currency for prices.
|
|
360
237
|
* @param queryOptions.includeMarketData - Whether to include market data.
|
|
361
238
|
* @param options - Fetch options including cache settings.
|
|
362
|
-
* @returns
|
|
239
|
+
* @returns The spot prices with market data.
|
|
363
240
|
*/
|
|
364
|
-
|
|
241
|
+
async fetchV2SpotPrices(chainId, tokenAddresses, queryOptions, options) {
|
|
242
|
+
if (tokenAddresses.length === 0) {
|
|
243
|
+
return {};
|
|
244
|
+
}
|
|
365
245
|
const chainIdDecimal = parseInt(chainId, 16);
|
|
366
246
|
const currency = queryOptions?.currency ?? 'usd';
|
|
367
247
|
const includeMarketData = queryOptions?.includeMarketData ?? true;
|
|
368
|
-
return {
|
|
248
|
+
return this.queryClient.fetchQuery({
|
|
369
249
|
queryKey: [
|
|
370
250
|
'prices',
|
|
371
251
|
'v2SpotPrices',
|
|
@@ -376,46 +256,23 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
376
256
|
includeMarketData,
|
|
377
257
|
},
|
|
378
258
|
],
|
|
379
|
-
queryFn:
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
vsCurrency: currency,
|
|
388
|
-
includeMarketData: queryOptions?.includeMarketData ?? true,
|
|
389
|
-
},
|
|
390
|
-
});
|
|
391
|
-
},
|
|
392
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
259
|
+
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v2/chains/${chainIdDecimal}/spot-prices`, {
|
|
260
|
+
signal,
|
|
261
|
+
params: {
|
|
262
|
+
tokenAddresses,
|
|
263
|
+
vsCurrency: currency,
|
|
264
|
+
includeMarketData: queryOptions?.includeMarketData ?? true,
|
|
265
|
+
},
|
|
266
|
+
}),
|
|
393
267
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
394
268
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Get spot prices for tokens on a chain with market data (v2 endpoint).
|
|
399
|
-
*
|
|
400
|
-
* @param chainId - The chain ID (hex format).
|
|
401
|
-
* @param tokenAddresses - Array of token addresses.
|
|
402
|
-
* @param queryOptions - Query options.
|
|
403
|
-
* @param queryOptions.currency - The currency for prices.
|
|
404
|
-
* @param queryOptions.includeMarketData - Whether to include market data.
|
|
405
|
-
* @param options - Fetch options including cache settings.
|
|
406
|
-
* @returns The spot prices with market data.
|
|
407
|
-
*/
|
|
408
|
-
async fetchV2SpotPrices(chainId, tokenAddresses, queryOptions, options) {
|
|
409
|
-
if (chainId === '' || tokenAddresses.length === 0) {
|
|
410
|
-
return {};
|
|
411
|
-
}
|
|
412
|
-
return this.queryClient.fetchQuery(this.getV2SpotPricesQueryOptions(chainId, tokenAddresses, queryOptions, options));
|
|
269
|
+
});
|
|
413
270
|
}
|
|
414
271
|
// ==========================================================================
|
|
415
272
|
// V3 SPOT PRICES (CAIP-19 based)
|
|
416
273
|
// ==========================================================================
|
|
417
274
|
/**
|
|
418
|
-
*
|
|
275
|
+
* Get spot prices by CAIP-19 asset IDs (v3 endpoint).
|
|
419
276
|
*
|
|
420
277
|
* @param assetIds - Array of CAIP-19 asset IDs.
|
|
421
278
|
* @param queryOptions - Query options.
|
|
@@ -423,13 +280,16 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
423
280
|
* @param queryOptions.includeMarketData - Whether to include market data.
|
|
424
281
|
* @param queryOptions.cacheOnly - Whether to use cache only.
|
|
425
282
|
* @param options - Fetch options including cache settings.
|
|
426
|
-
* @returns
|
|
283
|
+
* @returns The spot prices response.
|
|
427
284
|
*/
|
|
428
|
-
|
|
285
|
+
async fetchV3SpotPrices(assetIds, queryOptions, options) {
|
|
286
|
+
if (assetIds.length === 0) {
|
|
287
|
+
return {};
|
|
288
|
+
}
|
|
429
289
|
const currency = queryOptions?.currency ?? 'usd';
|
|
430
290
|
const includeMarketData = queryOptions?.includeMarketData ?? true;
|
|
431
291
|
const cacheOnly = queryOptions?.cacheOnly ?? false;
|
|
432
|
-
return {
|
|
292
|
+
return this.queryClient.fetchQuery({
|
|
433
293
|
queryKey: [
|
|
434
294
|
'prices',
|
|
435
295
|
'v3SpotPrices',
|
|
@@ -440,47 +300,24 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
440
300
|
cacheOnly,
|
|
441
301
|
},
|
|
442
302
|
],
|
|
443
|
-
queryFn:
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
includeMarketData,
|
|
453
|
-
cacheOnly,
|
|
454
|
-
},
|
|
455
|
-
});
|
|
456
|
-
},
|
|
457
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
303
|
+
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, '/v3/spot-prices', {
|
|
304
|
+
signal,
|
|
305
|
+
params: {
|
|
306
|
+
assetIds,
|
|
307
|
+
vsCurrency: currency,
|
|
308
|
+
includeMarketData,
|
|
309
|
+
cacheOnly,
|
|
310
|
+
},
|
|
311
|
+
}),
|
|
458
312
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
459
313
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* Get spot prices by CAIP-19 asset IDs (v3 endpoint).
|
|
464
|
-
*
|
|
465
|
-
* @param assetIds - Array of CAIP-19 asset IDs.
|
|
466
|
-
* @param queryOptions - Query options.
|
|
467
|
-
* @param queryOptions.currency - The currency for prices.
|
|
468
|
-
* @param queryOptions.includeMarketData - Whether to include market data.
|
|
469
|
-
* @param queryOptions.cacheOnly - Whether to use cache only.
|
|
470
|
-
* @param options - Fetch options including cache settings.
|
|
471
|
-
* @returns The spot prices response.
|
|
472
|
-
*/
|
|
473
|
-
async fetchV3SpotPrices(assetIds, queryOptions, options) {
|
|
474
|
-
if (assetIds.length === 0) {
|
|
475
|
-
return {};
|
|
476
|
-
}
|
|
477
|
-
return this.queryClient.fetchQuery(this.getV3SpotPricesQueryOptions(assetIds, queryOptions, options));
|
|
314
|
+
});
|
|
478
315
|
}
|
|
479
316
|
// ==========================================================================
|
|
480
317
|
// V1 HISTORICAL PRICES
|
|
481
318
|
// ==========================================================================
|
|
482
319
|
/**
|
|
483
|
-
*
|
|
320
|
+
* Get historical prices by CoinGecko coin ID (v1 endpoint).
|
|
484
321
|
*
|
|
485
322
|
* @param coinId - The CoinGecko coin ID.
|
|
486
323
|
* @param queryOptions - Query options.
|
|
@@ -489,10 +326,10 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
489
326
|
* @param queryOptions.from - Start timestamp.
|
|
490
327
|
* @param queryOptions.to - End timestamp.
|
|
491
328
|
* @param options - Fetch options including cache settings.
|
|
492
|
-
* @returns
|
|
329
|
+
* @returns The historical prices response.
|
|
493
330
|
*/
|
|
494
|
-
|
|
495
|
-
return {
|
|
331
|
+
async fetchV1HistoricalPricesByCoinId(coinId, queryOptions, options) {
|
|
332
|
+
return this.queryClient.fetchQuery({
|
|
496
333
|
queryKey: ['prices', 'v1HistoricalByCoinId', coinId, queryOptions],
|
|
497
334
|
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v1/historical-prices/${coinId}`, {
|
|
498
335
|
signal,
|
|
@@ -503,28 +340,12 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
503
340
|
to: queryOptions?.to,
|
|
504
341
|
},
|
|
505
342
|
}),
|
|
506
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
507
343
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
508
344
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Get historical prices by CoinGecko coin ID (v1 endpoint).
|
|
513
|
-
*
|
|
514
|
-
* @param coinId - The CoinGecko coin ID.
|
|
515
|
-
* @param queryOptions - Query options.
|
|
516
|
-
* @param queryOptions.currency - The currency for prices.
|
|
517
|
-
* @param queryOptions.timePeriod - The time period.
|
|
518
|
-
* @param queryOptions.from - Start timestamp.
|
|
519
|
-
* @param queryOptions.to - End timestamp.
|
|
520
|
-
* @param options - Fetch options including cache settings.
|
|
521
|
-
* @returns The historical prices response.
|
|
522
|
-
*/
|
|
523
|
-
async fetchV1HistoricalPricesByCoinId(coinId, queryOptions, options) {
|
|
524
|
-
return this.queryClient.fetchQuery(this.getV1HistoricalPricesByCoinIdQueryOptions(coinId, queryOptions, options));
|
|
345
|
+
});
|
|
525
346
|
}
|
|
526
347
|
/**
|
|
527
|
-
*
|
|
348
|
+
* Get historical prices for tokens on a chain (v1 endpoint).
|
|
528
349
|
*
|
|
529
350
|
* @param chainId - The chain ID (hex format).
|
|
530
351
|
* @param tokenAddresses - Array of token addresses.
|
|
@@ -534,11 +355,11 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
534
355
|
* @param queryOptions.from - Start timestamp.
|
|
535
356
|
* @param queryOptions.to - End timestamp.
|
|
536
357
|
* @param options - Fetch options including cache settings.
|
|
537
|
-
* @returns
|
|
358
|
+
* @returns The historical prices response.
|
|
538
359
|
*/
|
|
539
|
-
|
|
360
|
+
async fetchV1HistoricalPricesByTokenAddresses(chainId, tokenAddresses, queryOptions, options) {
|
|
540
361
|
const chainIdDecimal = parseInt(chainId, 16);
|
|
541
|
-
return {
|
|
362
|
+
return this.queryClient.fetchQuery({
|
|
542
363
|
queryKey: [
|
|
543
364
|
'prices',
|
|
544
365
|
'v1HistoricalByTokenAddresses',
|
|
@@ -558,29 +379,12 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
558
379
|
to: queryOptions?.to,
|
|
559
380
|
},
|
|
560
381
|
}),
|
|
561
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
562
382
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
563
383
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Get historical prices for tokens on a chain (v1 endpoint).
|
|
568
|
-
*
|
|
569
|
-
* @param chainId - The chain ID (hex format).
|
|
570
|
-
* @param tokenAddresses - Array of token addresses.
|
|
571
|
-
* @param queryOptions - Query options.
|
|
572
|
-
* @param queryOptions.currency - The currency for prices.
|
|
573
|
-
* @param queryOptions.timePeriod - The time period.
|
|
574
|
-
* @param queryOptions.from - Start timestamp.
|
|
575
|
-
* @param queryOptions.to - End timestamp.
|
|
576
|
-
* @param options - Fetch options including cache settings.
|
|
577
|
-
* @returns The historical prices response.
|
|
578
|
-
*/
|
|
579
|
-
async fetchV1HistoricalPricesByTokenAddresses(chainId, tokenAddresses, queryOptions, options) {
|
|
580
|
-
return this.queryClient.fetchQuery(this.getV1HistoricalPricesByTokenAddressesQueryOptions(chainId, tokenAddresses, queryOptions, options));
|
|
384
|
+
});
|
|
581
385
|
}
|
|
582
386
|
/**
|
|
583
|
-
*
|
|
387
|
+
* Get historical prices for a single token (v1 endpoint).
|
|
584
388
|
*
|
|
585
389
|
* @param chainId - The chain ID (hex format).
|
|
586
390
|
* @param tokenAddress - The token address.
|
|
@@ -588,13 +392,13 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
588
392
|
* @param queryOptions.currency - The currency for prices.
|
|
589
393
|
* @param queryOptions.timeRange - The time range.
|
|
590
394
|
* @param options - Fetch options including cache settings.
|
|
591
|
-
* @returns
|
|
395
|
+
* @returns The historical prices response.
|
|
592
396
|
*/
|
|
593
|
-
|
|
397
|
+
async fetchV1HistoricalPrices(chainId, tokenAddress, queryOptions, options) {
|
|
594
398
|
const chainIdDecimal = parseInt(chainId, 16);
|
|
595
399
|
const currency = queryOptions?.currency ?? 'usd';
|
|
596
400
|
const timeRange = queryOptions?.timeRange ?? '7d';
|
|
597
|
-
return {
|
|
401
|
+
return this.queryClient.fetchQuery({
|
|
598
402
|
queryKey: [
|
|
599
403
|
'prices',
|
|
600
404
|
'v1Historical',
|
|
@@ -610,30 +414,15 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
610
414
|
timePeriod: timeRange,
|
|
611
415
|
},
|
|
612
416
|
}),
|
|
613
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
614
417
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
615
418
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
/**
|
|
619
|
-
* Get historical prices for a single token (v1 endpoint).
|
|
620
|
-
*
|
|
621
|
-
* @param chainId - The chain ID (hex format).
|
|
622
|
-
* @param tokenAddress - The token address.
|
|
623
|
-
* @param queryOptions - Query options.
|
|
624
|
-
* @param queryOptions.currency - The currency for prices.
|
|
625
|
-
* @param queryOptions.timeRange - The time range.
|
|
626
|
-
* @param options - Fetch options including cache settings.
|
|
627
|
-
* @returns The historical prices response.
|
|
628
|
-
*/
|
|
629
|
-
async fetchV1HistoricalPrices(chainId, tokenAddress, queryOptions, options) {
|
|
630
|
-
return this.queryClient.fetchQuery(this.getV1HistoricalPricesQueryOptions(chainId, tokenAddress, queryOptions, options));
|
|
419
|
+
});
|
|
631
420
|
}
|
|
632
421
|
// ==========================================================================
|
|
633
422
|
// V3 HISTORICAL PRICES
|
|
634
423
|
// ==========================================================================
|
|
635
424
|
/**
|
|
636
|
-
*
|
|
425
|
+
* Get historical prices by CAIP-19 asset ID (v3 endpoint).
|
|
637
426
|
*
|
|
638
427
|
* @param chainId - The CAIP-2 chain ID.
|
|
639
428
|
* @param assetType - The asset type portion of CAIP-19.
|
|
@@ -644,10 +433,10 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
644
433
|
* @param queryOptions.to - End timestamp.
|
|
645
434
|
* @param queryOptions.interval - Data interval.
|
|
646
435
|
* @param options - Fetch options including cache settings.
|
|
647
|
-
* @returns
|
|
436
|
+
* @returns The historical prices response.
|
|
648
437
|
*/
|
|
649
|
-
|
|
650
|
-
return {
|
|
438
|
+
async fetchV3HistoricalPrices(chainId, assetType, queryOptions, options) {
|
|
439
|
+
return this.queryClient.fetchQuery({
|
|
651
440
|
queryKey: ['prices', 'v3Historical', chainId, assetType, queryOptions],
|
|
652
441
|
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v3/historical-prices/${chainId}/${assetType}`, {
|
|
653
442
|
signal,
|
|
@@ -659,45 +448,27 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
659
448
|
interval: queryOptions?.interval,
|
|
660
449
|
},
|
|
661
450
|
}),
|
|
662
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
663
451
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
664
452
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Get historical prices by CAIP-19 asset ID (v3 endpoint).
|
|
669
|
-
*
|
|
670
|
-
* @param chainId - The CAIP-2 chain ID.
|
|
671
|
-
* @param assetType - The asset type portion of CAIP-19.
|
|
672
|
-
* @param queryOptions - Query options.
|
|
673
|
-
* @param queryOptions.currency - The currency for prices.
|
|
674
|
-
* @param queryOptions.timePeriod - The time period.
|
|
675
|
-
* @param queryOptions.from - Start timestamp.
|
|
676
|
-
* @param queryOptions.to - End timestamp.
|
|
677
|
-
* @param queryOptions.interval - Data interval.
|
|
678
|
-
* @param options - Fetch options including cache settings.
|
|
679
|
-
* @returns The historical prices response.
|
|
680
|
-
*/
|
|
681
|
-
async fetchV3HistoricalPrices(chainId, assetType, queryOptions, options) {
|
|
682
|
-
return this.queryClient.fetchQuery(this.getV3HistoricalPricesQueryOptions(chainId, assetType, queryOptions, options));
|
|
453
|
+
});
|
|
683
454
|
}
|
|
684
455
|
// ==========================================================================
|
|
685
456
|
// V1 HISTORICAL PRICE GRAPH
|
|
686
457
|
// ==========================================================================
|
|
687
458
|
/**
|
|
688
|
-
*
|
|
459
|
+
* Get historical price graph data by CoinGecko coin ID (v1 endpoint).
|
|
689
460
|
*
|
|
690
461
|
* @param coinId - The CoinGecko coin ID.
|
|
691
462
|
* @param queryOptions - Query options.
|
|
692
463
|
* @param queryOptions.currency - The currency for prices.
|
|
693
464
|
* @param queryOptions.includeOHLC - Whether to include OHLC data.
|
|
694
465
|
* @param options - Fetch options including cache settings.
|
|
695
|
-
* @returns
|
|
466
|
+
* @returns The historical price graph response.
|
|
696
467
|
*/
|
|
697
|
-
|
|
468
|
+
async fetchV1HistoricalPriceGraphByCoinId(coinId, queryOptions, options) {
|
|
698
469
|
const currency = queryOptions?.currency ?? 'usd';
|
|
699
470
|
const includeOHLC = queryOptions?.includeOHLC ?? false;
|
|
700
|
-
return {
|
|
471
|
+
return this.queryClient.fetchQuery({
|
|
701
472
|
queryKey: ['prices', 'v1GraphByCoinId', coinId, currency, includeOHLC],
|
|
702
473
|
queryFn: ({ signal }) => this.fetch(base_client_1.API_URLS.PRICES, `/v1/historical-prices-graph/${coinId}`, {
|
|
703
474
|
signal,
|
|
@@ -706,26 +477,12 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
706
477
|
includeOHLC,
|
|
707
478
|
},
|
|
708
479
|
}),
|
|
709
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
710
480
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
711
481
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
/**
|
|
715
|
-
* Get historical price graph data by CoinGecko coin ID (v1 endpoint).
|
|
716
|
-
*
|
|
717
|
-
* @param coinId - The CoinGecko coin ID.
|
|
718
|
-
* @param queryOptions - Query options.
|
|
719
|
-
* @param queryOptions.currency - The currency for prices.
|
|
720
|
-
* @param queryOptions.includeOHLC - Whether to include OHLC data.
|
|
721
|
-
* @param options - Fetch options including cache settings.
|
|
722
|
-
* @returns The historical price graph response.
|
|
723
|
-
*/
|
|
724
|
-
async fetchV1HistoricalPriceGraphByCoinId(coinId, queryOptions, options) {
|
|
725
|
-
return this.queryClient.fetchQuery(this.getV1HistoricalPriceGraphByCoinIdQueryOptions(coinId, queryOptions, options));
|
|
482
|
+
});
|
|
726
483
|
}
|
|
727
484
|
/**
|
|
728
|
-
*
|
|
485
|
+
* Get historical price graph data by token address (v1 endpoint).
|
|
729
486
|
*
|
|
730
487
|
* @param chainId - The chain ID (hex format).
|
|
731
488
|
* @param tokenAddress - The token address.
|
|
@@ -733,13 +490,13 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
733
490
|
* @param queryOptions.currency - The currency for prices.
|
|
734
491
|
* @param queryOptions.includeOHLC - Whether to include OHLC data.
|
|
735
492
|
* @param options - Fetch options including cache settings.
|
|
736
|
-
* @returns
|
|
493
|
+
* @returns The historical price graph response.
|
|
737
494
|
*/
|
|
738
|
-
|
|
495
|
+
async fetchV1HistoricalPriceGraphByTokenAddress(chainId, tokenAddress, queryOptions, options) {
|
|
739
496
|
const chainIdDecimal = parseInt(chainId, 16);
|
|
740
497
|
const currency = queryOptions?.currency ?? 'usd';
|
|
741
498
|
const includeOHLC = queryOptions?.includeOHLC ?? false;
|
|
742
|
-
return {
|
|
499
|
+
return this.queryClient.fetchQuery({
|
|
743
500
|
queryKey: [
|
|
744
501
|
'prices',
|
|
745
502
|
'v1GraphByTokenAddress',
|
|
@@ -755,24 +512,9 @@ class PricesApiClient extends base_client_1.BaseApiClient {
|
|
|
755
512
|
includeOHLC,
|
|
756
513
|
},
|
|
757
514
|
}),
|
|
758
|
-
...(0, shared_types_1.getQueryOptionsOverrides)(options),
|
|
759
515
|
staleTime: options?.staleTime ?? base_client_1.STALE_TIMES.PRICES,
|
|
760
516
|
gcTime: options?.gcTime ?? base_client_1.GC_TIMES.DEFAULT,
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* Get historical price graph data by token address (v1 endpoint).
|
|
765
|
-
*
|
|
766
|
-
* @param chainId - The chain ID (hex format).
|
|
767
|
-
* @param tokenAddress - The token address.
|
|
768
|
-
* @param queryOptions - Query options.
|
|
769
|
-
* @param queryOptions.currency - The currency for prices.
|
|
770
|
-
* @param queryOptions.includeOHLC - Whether to include OHLC data.
|
|
771
|
-
* @param options - Fetch options including cache settings.
|
|
772
|
-
* @returns The historical price graph response.
|
|
773
|
-
*/
|
|
774
|
-
async fetchV1HistoricalPriceGraphByTokenAddress(chainId, tokenAddress, queryOptions, options) {
|
|
775
|
-
return this.queryClient.fetchQuery(this.getV1HistoricalPriceGraphByTokenAddressQueryOptions(chainId, tokenAddress, queryOptions, options));
|
|
517
|
+
});
|
|
776
518
|
}
|
|
777
519
|
}
|
|
778
520
|
exports.PricesApiClient = PricesApiClient;
|