@metamask-previews/core-backend 9.0.0-preview-4f4c98e → 9.0.0-preview-eb263b0ee

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 (301) hide show
  1. package/CHANGELOG.md +0 -5
  2. package/dist/ApiPlatformClientService-method-action-types.cjs +7 -0
  3. package/dist/ApiPlatformClientService-method-action-types.cjs.map +1 -0
  4. package/dist/{ApiPlatformClientService-method-action-types.d.ts → ApiPlatformClientService-method-action-types.d.cts} +2 -2
  5. package/dist/ApiPlatformClientService-method-action-types.d.cts.map +1 -0
  6. package/dist/ApiPlatformClientService-method-action-types.d.mts +21 -0
  7. package/dist/ApiPlatformClientService-method-action-types.d.mts.map +1 -0
  8. package/dist/{ApiPlatformClientService-method-action-types.js → ApiPlatformClientService-method-action-types.mjs} +1 -1
  9. package/dist/ApiPlatformClientService-method-action-types.mjs.map +1 -0
  10. package/dist/ApiPlatformClientService.cjs +82 -0
  11. package/dist/ApiPlatformClientService.cjs.map +1 -0
  12. package/dist/{ApiPlatformClientService.d.ts → ApiPlatformClientService.d.cts} +5 -5
  13. package/dist/ApiPlatformClientService.d.cts.map +1 -0
  14. package/dist/ApiPlatformClientService.d.mts +86 -0
  15. package/dist/ApiPlatformClientService.d.mts.map +1 -0
  16. package/dist/{ApiPlatformClientService.js → ApiPlatformClientService.mjs} +2 -2
  17. package/dist/ApiPlatformClientService.mjs.map +1 -0
  18. package/dist/api/ApiPlatformClient.cjs +177 -0
  19. package/dist/api/ApiPlatformClient.cjs.map +1 -0
  20. package/dist/api/{ApiPlatformClient.d.ts → ApiPlatformClient.d.cts} +8 -8
  21. package/dist/api/ApiPlatformClient.d.cts.map +1 -0
  22. package/dist/api/ApiPlatformClient.d.mts +127 -0
  23. package/dist/api/ApiPlatformClient.d.mts.map +1 -0
  24. package/dist/api/{ApiPlatformClient.js → ApiPlatformClient.mjs} +8 -8
  25. package/dist/api/ApiPlatformClient.mjs.map +1 -0
  26. package/dist/api/accounts/client.cjs +850 -0
  27. package/dist/api/accounts/client.cjs.map +1 -0
  28. package/dist/api/accounts/{client.d.ts → client.d.cts} +5 -5
  29. package/dist/api/accounts/client.d.cts.map +1 -0
  30. package/dist/api/accounts/client.d.mts +500 -0
  31. package/dist/api/accounts/client.d.mts.map +1 -0
  32. package/dist/api/accounts/{client.js → client.mjs} +3 -3
  33. package/dist/api/accounts/client.mjs.map +1 -0
  34. package/dist/api/accounts/index.cjs +11 -0
  35. package/dist/api/accounts/index.cjs.map +1 -0
  36. package/dist/api/accounts/{index.d.ts → index.d.cts} +4 -4
  37. package/dist/api/accounts/index.d.cts.map +1 -0
  38. package/dist/api/accounts/index.d.mts +7 -0
  39. package/dist/api/accounts/index.d.mts.map +1 -0
  40. package/dist/api/accounts/index.mjs +6 -0
  41. package/dist/api/accounts/index.mjs.map +1 -0
  42. package/dist/api/accounts/types.cjs +22 -0
  43. package/dist/api/accounts/types.cjs.map +1 -0
  44. package/dist/api/accounts/{types.d.ts → types.d.cts} +3 -3
  45. package/dist/api/accounts/types.d.cts.map +1 -0
  46. package/dist/api/accounts/types.d.mts +286 -0
  47. package/dist/api/accounts/types.d.mts.map +1 -0
  48. package/dist/api/accounts/{types.js → types.mjs} +1 -1
  49. package/dist/api/accounts/types.mjs.map +1 -0
  50. package/dist/api/base-client.cjs +151 -0
  51. package/dist/api/base-client.cjs.map +1 -0
  52. package/dist/api/{base-client.d.ts → base-client.d.cts} +5 -6
  53. package/dist/api/base-client.d.cts.map +1 -0
  54. package/dist/api/base-client.d.mts +54 -0
  55. package/dist/api/base-client.d.mts.map +1 -0
  56. package/dist/api/{base-client.js → base-client.mjs} +3 -3
  57. package/dist/api/base-client.mjs.map +1 -0
  58. package/dist/api/index.cjs +37 -0
  59. package/dist/api/index.cjs.map +1 -0
  60. package/dist/api/{index.d.ts → index.d.cts} +14 -14
  61. package/dist/api/index.d.cts.map +1 -0
  62. package/dist/api/index.d.mts +18 -0
  63. package/dist/api/index.d.mts.map +1 -0
  64. package/dist/api/index.mjs +18 -0
  65. package/dist/api/index.mjs.map +1 -0
  66. package/dist/api/prices/client.cjs +779 -0
  67. package/dist/api/prices/client.cjs.map +1 -0
  68. package/dist/api/prices/{client.d.ts → client.d.cts} +5 -5
  69. package/dist/api/prices/client.d.cts.map +1 -0
  70. package/dist/api/prices/client.d.mts +447 -0
  71. package/dist/api/prices/client.d.mts.map +1 -0
  72. package/dist/api/prices/{client.js → client.mjs} +3 -3
  73. package/dist/api/prices/client.mjs.map +1 -0
  74. package/dist/api/prices/index.cjs +9 -0
  75. package/dist/api/prices/index.cjs.map +1 -0
  76. package/dist/api/prices/{index.d.ts → index.d.cts} +3 -3
  77. package/dist/api/prices/index.d.cts.map +1 -0
  78. package/dist/api/prices/index.d.mts +6 -0
  79. package/dist/api/prices/index.d.mts.map +1 -0
  80. package/dist/api/prices/index.mjs +5 -0
  81. package/dist/api/prices/index.mjs.map +1 -0
  82. package/dist/api/prices/types.cjs +7 -0
  83. package/dist/api/prices/types.cjs.map +1 -0
  84. package/dist/api/prices/{types.d.ts → types.d.cts} +1 -1
  85. package/dist/api/prices/types.d.cts.map +1 -0
  86. package/dist/api/prices/types.d.mts +61 -0
  87. package/dist/api/prices/types.d.mts.map +1 -0
  88. package/dist/api/prices/{types.js → types.mjs} +1 -1
  89. package/dist/api/prices/types.mjs.map +1 -0
  90. package/dist/api/shared-types.cjs +110 -0
  91. package/dist/api/shared-types.cjs.map +1 -0
  92. package/dist/api/{shared-types.d.ts → shared-types.d.cts} +6 -6
  93. package/dist/api/shared-types.d.cts.map +1 -0
  94. package/dist/api/shared-types.d.mts +151 -0
  95. package/dist/api/shared-types.d.mts.map +1 -0
  96. package/dist/api/{shared-types.js → shared-types.mjs} +1 -1
  97. package/dist/api/shared-types.mjs.map +1 -0
  98. package/dist/api/test-utils.cjs +70 -0
  99. package/dist/api/test-utils.cjs.map +1 -0
  100. package/dist/api/{test-utils.d.ts → test-utils.d.cts} +3 -2
  101. package/dist/api/test-utils.d.cts.map +1 -0
  102. package/dist/api/test-utils.d.mts +30 -0
  103. package/dist/api/test-utils.d.mts.map +1 -0
  104. package/dist/api/{test-utils.js → test-utils.mjs} +3 -3
  105. package/dist/api/test-utils.mjs.map +1 -0
  106. package/dist/api/token/client.cjs +500 -0
  107. package/dist/api/token/client.cjs.map +1 -0
  108. package/dist/api/token/{client.d.ts → client.d.cts} +5 -5
  109. package/dist/api/token/client.d.cts.map +1 -0
  110. package/dist/api/token/client.d.mts +362 -0
  111. package/dist/api/token/client.d.mts.map +1 -0
  112. package/dist/api/token/{client.js → client.mjs} +3 -3
  113. package/dist/api/token/client.mjs.map +1 -0
  114. package/dist/api/token/index.cjs +9 -0
  115. package/dist/api/token/index.cjs.map +1 -0
  116. package/dist/api/token/{index.d.ts → index.d.cts} +3 -3
  117. package/dist/api/token/index.d.cts.map +1 -0
  118. package/dist/api/token/index.d.mts +6 -0
  119. package/dist/api/token/index.d.mts.map +1 -0
  120. package/dist/api/token/index.mjs +5 -0
  121. package/dist/api/token/index.mjs.map +1 -0
  122. package/dist/api/token/types.cjs +7 -0
  123. package/dist/api/token/types.cjs.map +1 -0
  124. package/dist/api/token/{types.d.ts → types.d.cts} +1 -1
  125. package/dist/api/token/types.d.cts.map +1 -0
  126. package/dist/api/token/types.d.mts +124 -0
  127. package/dist/api/token/types.d.mts.map +1 -0
  128. package/dist/api/token/{types.js → types.mjs} +1 -1
  129. package/dist/api/token/types.mjs.map +1 -0
  130. package/dist/api/tokens/client.cjs +132 -0
  131. package/dist/api/tokens/client.cjs.map +1 -0
  132. package/dist/api/tokens/{client.d.ts → client.d.cts} +5 -5
  133. package/dist/api/tokens/client.d.cts.map +1 -0
  134. package/dist/api/tokens/client.d.mts +69 -0
  135. package/dist/api/tokens/client.d.mts.map +1 -0
  136. package/dist/api/tokens/{client.js → client.mjs} +3 -3
  137. package/dist/api/tokens/client.mjs.map +1 -0
  138. package/dist/api/tokens/index.cjs +9 -0
  139. package/dist/api/tokens/index.cjs.map +1 -0
  140. package/dist/api/tokens/{index.d.ts → index.d.cts} +3 -3
  141. package/dist/api/tokens/index.d.cts.map +1 -0
  142. package/dist/api/tokens/index.d.mts +6 -0
  143. package/dist/api/tokens/index.d.mts.map +1 -0
  144. package/dist/api/tokens/index.mjs +5 -0
  145. package/dist/api/tokens/index.mjs.map +1 -0
  146. package/dist/api/tokens/types.cjs +7 -0
  147. package/dist/api/tokens/types.cjs.map +1 -0
  148. package/dist/api/tokens/{types.d.ts → types.d.cts} +1 -1
  149. package/dist/api/tokens/types.d.cts.map +1 -0
  150. package/dist/api/tokens/types.d.mts +87 -0
  151. package/dist/api/tokens/types.d.mts.map +1 -0
  152. package/dist/api/tokens/{types.js → types.mjs} +1 -1
  153. package/dist/api/tokens/types.mjs.map +1 -0
  154. package/dist/index.cjs +55 -0
  155. package/dist/index.cjs.map +1 -0
  156. package/dist/{index.d.ts → index.d.cts} +12 -12
  157. package/dist/index.d.cts.map +1 -0
  158. package/dist/index.d.mts +12 -0
  159. package/dist/index.d.mts.map +1 -0
  160. package/dist/{index.js → index.mjs} +6 -6
  161. package/dist/index.mjs.map +1 -0
  162. package/dist/logger.cjs +7 -0
  163. package/dist/logger.cjs.map +1 -0
  164. package/dist/logger.d.cts +5 -0
  165. package/dist/logger.d.cts.map +1 -0
  166. package/dist/logger.d.mts +5 -0
  167. package/dist/logger.d.mts.map +1 -0
  168. package/dist/logger.mjs +4 -0
  169. package/dist/logger.mjs.map +1 -0
  170. package/dist/types.cjs +3 -0
  171. package/dist/types.cjs.map +1 -0
  172. package/dist/{types.d.ts → types.d.cts} +1 -1
  173. package/dist/types.d.cts.map +1 -0
  174. package/dist/types.d.mts +73 -0
  175. package/dist/types.d.mts.map +1 -0
  176. package/dist/types.mjs +2 -0
  177. package/dist/types.mjs.map +1 -0
  178. package/dist/ws/AccountActivityService.cjs +437 -0
  179. package/dist/ws/AccountActivityService.cjs.map +1 -0
  180. package/dist/ws/{AccountActivityService.d.ts → AccountActivityService.d.cts} +10 -10
  181. package/dist/ws/AccountActivityService.d.cts.map +1 -0
  182. package/dist/ws/AccountActivityService.d.mts +136 -0
  183. package/dist/ws/AccountActivityService.d.mts.map +1 -0
  184. package/dist/ws/{AccountActivityService.js → AccountActivityService.mjs} +4 -4
  185. package/dist/ws/AccountActivityService.mjs.map +1 -0
  186. package/dist/ws/BackendWebSocketService-method-action-types.cjs +7 -0
  187. package/dist/ws/BackendWebSocketService-method-action-types.cjs.map +1 -0
  188. package/dist/ws/{BackendWebSocketService-method-action-types.d.ts → BackendWebSocketService-method-action-types.d.cts} +2 -2
  189. package/dist/ws/BackendWebSocketService-method-action-types.d.cts.map +1 -0
  190. package/dist/ws/BackendWebSocketService-method-action-types.d.mts +252 -0
  191. package/dist/ws/BackendWebSocketService-method-action-types.d.mts.map +1 -0
  192. package/dist/ws/{BackendWebSocketService-method-action-types.js → BackendWebSocketService-method-action-types.mjs} +1 -1
  193. package/dist/ws/BackendWebSocketService-method-action-types.mjs.map +1 -0
  194. package/dist/ws/BackendWebSocketService.cjs +1062 -0
  195. package/dist/ws/BackendWebSocketService.cjs.map +1 -0
  196. package/dist/ws/{BackendWebSocketService.d.ts → BackendWebSocketService.d.cts} +7 -7
  197. package/dist/ws/BackendWebSocketService.d.cts.map +1 -0
  198. package/dist/ws/BackendWebSocketService.d.mts +406 -0
  199. package/dist/ws/BackendWebSocketService.d.mts.map +1 -0
  200. package/dist/ws/{BackendWebSocketService.js → BackendWebSocketService.mjs} +5 -5
  201. package/dist/ws/BackendWebSocketService.mjs.map +1 -0
  202. package/dist/ws/ohlcv/OHLCVService-method-action-types.cjs +7 -0
  203. package/dist/ws/ohlcv/OHLCVService-method-action-types.cjs.map +1 -0
  204. package/dist/ws/ohlcv/{OHLCVService-method-action-types.d.ts → OHLCVService-method-action-types.d.cts} +2 -2
  205. package/dist/ws/ohlcv/OHLCVService-method-action-types.d.cts.map +1 -0
  206. package/dist/ws/ohlcv/OHLCVService-method-action-types.d.mts +35 -0
  207. package/dist/ws/ohlcv/OHLCVService-method-action-types.d.mts.map +1 -0
  208. package/dist/ws/ohlcv/{OHLCVService-method-action-types.js → OHLCVService-method-action-types.mjs} +1 -1
  209. package/dist/ws/ohlcv/OHLCVService-method-action-types.mjs.map +1 -0
  210. package/dist/ws/ohlcv/OHLCVService.cjs +471 -0
  211. package/dist/ws/ohlcv/OHLCVService.cjs.map +1 -0
  212. package/dist/ws/ohlcv/{OHLCVService.d.ts → OHLCVService.d.cts} +9 -9
  213. package/dist/ws/ohlcv/OHLCVService.d.cts.map +1 -0
  214. package/dist/ws/ohlcv/OHLCVService.d.mts +111 -0
  215. package/dist/ws/ohlcv/OHLCVService.d.mts.map +1 -0
  216. package/dist/ws/ohlcv/{OHLCVService.js → OHLCVService.mjs} +5 -5
  217. package/dist/ws/ohlcv/OHLCVService.mjs.map +1 -0
  218. package/dist/ws/ohlcv/index.cjs +9 -0
  219. package/dist/ws/ohlcv/index.cjs.map +1 -0
  220. package/dist/ws/ohlcv/{index.d.ts → index.d.cts} +5 -5
  221. package/dist/ws/ohlcv/index.d.cts.map +1 -0
  222. package/dist/ws/ohlcv/index.d.mts +5 -0
  223. package/dist/ws/ohlcv/index.d.mts.map +1 -0
  224. package/dist/ws/ohlcv/index.mjs +3 -0
  225. package/dist/ws/ohlcv/index.mjs.map +1 -0
  226. package/dist/ws/ohlcv/types.cjs +6 -0
  227. package/dist/ws/ohlcv/types.cjs.map +1 -0
  228. package/dist/ws/ohlcv/{types.d.ts → types.d.cts} +1 -1
  229. package/dist/ws/ohlcv/types.d.cts.map +1 -0
  230. package/dist/ws/ohlcv/types.d.mts +32 -0
  231. package/dist/ws/ohlcv/types.d.mts.map +1 -0
  232. package/dist/ws/ohlcv/{types.js → types.mjs} +1 -1
  233. package/dist/ws/ohlcv/types.mjs.map +1 -0
  234. package/package.json +17 -13
  235. package/dist/ApiPlatformClientService-method-action-types.d.ts.map +0 -1
  236. package/dist/ApiPlatformClientService-method-action-types.js.map +0 -1
  237. package/dist/ApiPlatformClientService.d.ts.map +0 -1
  238. package/dist/ApiPlatformClientService.js.map +0 -1
  239. package/dist/api/ApiPlatformClient.d.ts.map +0 -1
  240. package/dist/api/ApiPlatformClient.js.map +0 -1
  241. package/dist/api/accounts/client.d.ts.map +0 -1
  242. package/dist/api/accounts/client.js.map +0 -1
  243. package/dist/api/accounts/index.d.ts.map +0 -1
  244. package/dist/api/accounts/index.js +0 -6
  245. package/dist/api/accounts/index.js.map +0 -1
  246. package/dist/api/accounts/types.d.ts.map +0 -1
  247. package/dist/api/accounts/types.js.map +0 -1
  248. package/dist/api/base-client.d.ts.map +0 -1
  249. package/dist/api/base-client.js.map +0 -1
  250. package/dist/api/index.d.ts.map +0 -1
  251. package/dist/api/index.js +0 -18
  252. package/dist/api/index.js.map +0 -1
  253. package/dist/api/prices/client.d.ts.map +0 -1
  254. package/dist/api/prices/client.js.map +0 -1
  255. package/dist/api/prices/index.d.ts.map +0 -1
  256. package/dist/api/prices/index.js +0 -5
  257. package/dist/api/prices/index.js.map +0 -1
  258. package/dist/api/prices/types.d.ts.map +0 -1
  259. package/dist/api/prices/types.js.map +0 -1
  260. package/dist/api/shared-types.d.ts.map +0 -1
  261. package/dist/api/shared-types.js.map +0 -1
  262. package/dist/api/test-utils.d.ts.map +0 -1
  263. package/dist/api/test-utils.js.map +0 -1
  264. package/dist/api/token/client.d.ts.map +0 -1
  265. package/dist/api/token/client.js.map +0 -1
  266. package/dist/api/token/index.d.ts.map +0 -1
  267. package/dist/api/token/index.js +0 -5
  268. package/dist/api/token/index.js.map +0 -1
  269. package/dist/api/token/types.d.ts.map +0 -1
  270. package/dist/api/token/types.js.map +0 -1
  271. package/dist/api/tokens/client.d.ts.map +0 -1
  272. package/dist/api/tokens/client.js.map +0 -1
  273. package/dist/api/tokens/index.d.ts.map +0 -1
  274. package/dist/api/tokens/index.js +0 -5
  275. package/dist/api/tokens/index.js.map +0 -1
  276. package/dist/api/tokens/types.d.ts.map +0 -1
  277. package/dist/api/tokens/types.js.map +0 -1
  278. package/dist/index.d.ts.map +0 -1
  279. package/dist/index.js.map +0 -1
  280. package/dist/logger.d.ts +0 -4
  281. package/dist/logger.d.ts.map +0 -1
  282. package/dist/logger.js +0 -4
  283. package/dist/logger.js.map +0 -1
  284. package/dist/types.d.ts.map +0 -1
  285. package/dist/types.js +0 -2
  286. package/dist/types.js.map +0 -1
  287. package/dist/ws/AccountActivityService.d.ts.map +0 -1
  288. package/dist/ws/AccountActivityService.js.map +0 -1
  289. package/dist/ws/BackendWebSocketService-method-action-types.d.ts.map +0 -1
  290. package/dist/ws/BackendWebSocketService-method-action-types.js.map +0 -1
  291. package/dist/ws/BackendWebSocketService.d.ts.map +0 -1
  292. package/dist/ws/BackendWebSocketService.js.map +0 -1
  293. package/dist/ws/ohlcv/OHLCVService-method-action-types.d.ts.map +0 -1
  294. package/dist/ws/ohlcv/OHLCVService-method-action-types.js.map +0 -1
  295. package/dist/ws/ohlcv/OHLCVService.d.ts.map +0 -1
  296. package/dist/ws/ohlcv/OHLCVService.js.map +0 -1
  297. package/dist/ws/ohlcv/index.d.ts.map +0 -1
  298. package/dist/ws/ohlcv/index.js +0 -3
  299. package/dist/ws/ohlcv/index.js.map +0 -1
  300. package/dist/ws/ohlcv/types.d.ts.map +0 -1
  301. package/dist/ws/ohlcv/types.js.map +0 -1
@@ -0,0 +1,779 @@
1
+ "use strict";
2
+ /**
3
+ * Prices API Client - price.api.cx.metamask.io
4
+ *
5
+ * Handles all price-related API calls including:
6
+ * - Supported networks
7
+ * - Exchange rates
8
+ * - Spot prices (v1, v2, v3)
9
+ * - Historical prices
10
+ * - Price graphs
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.PricesApiClient = void 0;
14
+ const base_client_js_1 = require("../base-client.cjs");
15
+ const shared_types_js_1 = require("../shared-types.cjs");
16
+ /**
17
+ * Prices API Client.
18
+ * Provides methods for interacting with the Price API.
19
+ */
20
+ class PricesApiClient extends base_client_js_1.BaseApiClient {
21
+ // ==========================================================================
22
+ // CACHE MANAGEMENT
23
+ // ==========================================================================
24
+ /**
25
+ * Invalidate all price queries.
26
+ */
27
+ async invalidatePrices() {
28
+ await this.queryClient.invalidateQueries({
29
+ queryKey: ['prices'],
30
+ });
31
+ }
32
+ // ==========================================================================
33
+ // SUPPORTED NETWORKS
34
+ // ==========================================================================
35
+ /**
36
+ * Returns the TanStack Query options object for price v1 supported networks.
37
+ *
38
+ * @param options - Fetch options including cache settings.
39
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
40
+ */
41
+ getPriceV1SupportedNetworksQueryOptions(options) {
42
+ return {
43
+ queryKey: ['prices', 'v1SupportedNetworks'],
44
+ queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.PRICES, '/v1/supportedNetworks', { signal }),
45
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
46
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.SUPPORTED_NETWORKS,
47
+ gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.EXTENDED,
48
+ };
49
+ }
50
+ /**
51
+ * Get price supported networks (v1 endpoint).
52
+ *
53
+ * @param options - Fetch options including cache settings.
54
+ * @returns The supported networks response.
55
+ */
56
+ async fetchPriceV1SupportedNetworks(options) {
57
+ return this.queryClient.fetchQuery(this.getPriceV1SupportedNetworksQueryOptions(options));
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 {
67
+ queryKey: ['prices', 'v2SupportedNetworks'],
68
+ queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.PRICES, '/v2/supportedNetworks', { signal }),
69
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
70
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.SUPPORTED_NETWORKS,
71
+ gcTime: options?.gcTime ?? base_client_js_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));
82
+ }
83
+ // ==========================================================================
84
+ // EXCHANGE RATES
85
+ // ==========================================================================
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_js_1.API_URLS.PRICES, '/v1/exchange-rates', {
101
+ signal,
102
+ params: { baseCurrency },
103
+ });
104
+ },
105
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
106
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.EXCHANGE_RATES,
107
+ gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
108
+ };
109
+ }
110
+ /**
111
+ * Get all exchange rates for a base currency (v1 endpoint).
112
+ *
113
+ * @param baseCurrency - The base currency code.
114
+ * @param options - Fetch options including cache settings.
115
+ * @returns The exchange rates response.
116
+ */
117
+ async fetchV1ExchangeRates(baseCurrency, options) {
118
+ if (baseCurrency === '') {
119
+ return {};
120
+ }
121
+ return this.queryClient.fetchQuery(this.getV1ExchangeRatesQueryOptions(baseCurrency, options));
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_js_1.API_URLS.PRICES, '/v1/exchange-rates/fiat', { signal }),
133
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
134
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.EXCHANGE_RATES,
135
+ gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
136
+ };
137
+ }
138
+ /**
139
+ * Get fiat exchange rates (v1 endpoint).
140
+ *
141
+ * @param options - Fetch options including cache settings.
142
+ * @returns The exchange rates response.
143
+ */
144
+ async fetchV1FiatExchangeRates(options) {
145
+ return this.queryClient.fetchQuery(this.getV1FiatExchangeRatesQueryOptions(options));
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_js_1.API_URLS.PRICES, '/v1/exchange-rates/crypto', { signal }),
157
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
158
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.EXCHANGE_RATES,
159
+ gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
160
+ };
161
+ }
162
+ /**
163
+ * Get crypto exchange rates (v1 endpoint).
164
+ *
165
+ * @param options - Fetch options including cache settings.
166
+ * @returns The exchange rates response.
167
+ */
168
+ async fetchV1CryptoExchangeRates(options) {
169
+ return this.queryClient.fetchQuery(this.getV1CryptoExchangeRatesQueryOptions(options));
170
+ }
171
+ // ==========================================================================
172
+ // V1 SPOT PRICES (CoinGecko ID based)
173
+ // ==========================================================================
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_js_1.API_URLS.PRICES, '/v1/spot-prices', {
193
+ signal,
194
+ params: { coinIds },
195
+ });
196
+ },
197
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
198
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
199
+ gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
200
+ };
201
+ }
202
+ /**
203
+ * Get spot prices by CoinGecko coin IDs (v1 endpoint).
204
+ *
205
+ * @param coinIds - Array of CoinGecko coin IDs.
206
+ * @param options - Fetch options including cache settings.
207
+ * @returns The spot prices by coin ID.
208
+ */
209
+ async fetchV1SpotPricesByCoinIds(coinIds, options) {
210
+ if (coinIds.length === 0) {
211
+ return {};
212
+ }
213
+ return this.queryClient.fetchQuery(this.getV1SpotPricesByCoinIdsQueryOptions(coinIds, options));
214
+ }
215
+ /**
216
+ * Returns the TanStack Query options object for v1 spot price by coin ID.
217
+ *
218
+ * @param coinId - The CoinGecko coin ID.
219
+ * @param currency - The currency for prices.
220
+ * @param options - Fetch options including cache settings.
221
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
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_js_1.API_URLS.PRICES, `/v1/spot-prices/${coinId}`, {
231
+ signal,
232
+ params: { vsCurrency: currency },
233
+ });
234
+ },
235
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
236
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
237
+ gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
238
+ };
239
+ }
240
+ /**
241
+ * Get spot price for a single CoinGecko coin ID (v1 endpoint).
242
+ *
243
+ * @param coinId - The CoinGecko coin ID.
244
+ * @param currency - The currency for prices.
245
+ * @param options - Fetch options including cache settings.
246
+ * @returns The spot price data.
247
+ */
248
+ async fetchV1SpotPriceByCoinId(coinId, currency = 'usd', options) {
249
+ return this.queryClient.fetchQuery(this.getV1SpotPriceByCoinIdQueryOptions(coinId, currency, options));
250
+ }
251
+ // ==========================================================================
252
+ // V1 SPOT PRICES (Token Address based)
253
+ // ==========================================================================
254
+ /**
255
+ * Returns the TanStack Query options object for v1 token prices.
256
+ *
257
+ * @param chainId - The chain ID (hex format).
258
+ * @param tokenAddresses - Array of token addresses.
259
+ * @param queryOptions - Query options.
260
+ * @param queryOptions.currency - The currency for prices.
261
+ * @param queryOptions.includeMarketData - Whether to include market data.
262
+ * @param options - Fetch options including cache settings.
263
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
264
+ */
265
+ getV1TokenPricesQueryOptions(chainId, tokenAddresses, queryOptions, options) {
266
+ const chainIdDecimal = parseInt(chainId, 16);
267
+ const currency = queryOptions?.currency ?? 'usd';
268
+ return {
269
+ queryKey: [
270
+ 'prices',
271
+ 'v1TokenPrices',
272
+ {
273
+ chainId,
274
+ tokenAddresses: [...tokenAddresses].sort(),
275
+ currency,
276
+ includeMarketData: queryOptions?.includeMarketData,
277
+ },
278
+ ],
279
+ queryFn: async ({ signal, }) => {
280
+ if (chainId === '' || tokenAddresses.length === 0) {
281
+ return {};
282
+ }
283
+ return this.fetch(base_client_js_1.API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/spot-prices`, {
284
+ signal,
285
+ params: {
286
+ tokenAddresses,
287
+ vsCurrency: currency,
288
+ includeMarketData: queryOptions?.includeMarketData,
289
+ },
290
+ });
291
+ },
292
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
293
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
294
+ gcTime: options?.gcTime ?? base_client_js_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));
313
+ }
314
+ /**
315
+ * Returns the TanStack Query options object for v1 token price.
316
+ *
317
+ * @param chainId - The chain ID (hex format).
318
+ * @param tokenAddress - The token address.
319
+ * @param currency - The currency for prices.
320
+ * @param options - Fetch options including cache settings.
321
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
322
+ */
323
+ getV1TokenPriceQueryOptions(chainId, tokenAddress, currency = 'usd', options) {
324
+ const chainIdDecimal = parseInt(chainId, 16);
325
+ return {
326
+ queryKey: ['prices', 'v1TokenPrice', chainId, tokenAddress, currency],
327
+ queryFn: async ({ signal, }) => {
328
+ return this.fetch(base_client_js_1.API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/spot-prices/${tokenAddress}`, {
329
+ signal,
330
+ params: { vsCurrency: currency },
331
+ });
332
+ },
333
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
334
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
335
+ gcTime: options?.gcTime ?? base_client_js_1.GC_TIMES.DEFAULT,
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));
349
+ }
350
+ // ==========================================================================
351
+ // V2 SPOT PRICES
352
+ // ==========================================================================
353
+ /**
354
+ * Returns the TanStack Query options object for v2 spot prices.
355
+ *
356
+ * @param chainId - The chain ID (hex format).
357
+ * @param tokenAddresses - Array of token addresses.
358
+ * @param queryOptions - Query options.
359
+ * @param queryOptions.currency - The currency for prices.
360
+ * @param queryOptions.includeMarketData - Whether to include market data.
361
+ * @param options - Fetch options including cache settings.
362
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
363
+ */
364
+ getV2SpotPricesQueryOptions(chainId, tokenAddresses, queryOptions, options) {
365
+ const chainIdDecimal = parseInt(chainId, 16);
366
+ const currency = queryOptions?.currency ?? 'usd';
367
+ const includeMarketData = queryOptions?.includeMarketData ?? true;
368
+ return {
369
+ queryKey: [
370
+ 'prices',
371
+ 'v2SpotPrices',
372
+ {
373
+ chainId,
374
+ tokenAddresses: [...tokenAddresses].sort(),
375
+ currency,
376
+ includeMarketData,
377
+ },
378
+ ],
379
+ queryFn: async ({ signal, }) => {
380
+ if (chainId === '' || tokenAddresses.length === 0) {
381
+ return {};
382
+ }
383
+ return this.fetch(base_client_js_1.API_URLS.PRICES, `/v2/chains/${chainIdDecimal}/spot-prices`, {
384
+ signal,
385
+ params: {
386
+ tokenAddresses,
387
+ vsCurrency: currency,
388
+ includeMarketData: queryOptions?.includeMarketData ?? true,
389
+ },
390
+ });
391
+ },
392
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
393
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
394
+ gcTime: options?.gcTime ?? base_client_js_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));
413
+ }
414
+ // ==========================================================================
415
+ // V3 SPOT PRICES (CAIP-19 based)
416
+ // ==========================================================================
417
+ /**
418
+ * Returns the TanStack Query options object for v3 spot prices.
419
+ *
420
+ * @param assetIds - Array of CAIP-19 asset IDs.
421
+ * @param queryOptions - Query options.
422
+ * @param queryOptions.currency - The currency for prices.
423
+ * @param queryOptions.includeMarketData - Whether to include market data.
424
+ * @param queryOptions.cacheOnly - Whether to use cache only.
425
+ * @param options - Fetch options including cache settings.
426
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
427
+ */
428
+ getV3SpotPricesQueryOptions(assetIds, queryOptions, options) {
429
+ const currency = queryOptions?.currency ?? 'usd';
430
+ const includeMarketData = queryOptions?.includeMarketData ?? true;
431
+ const cacheOnly = queryOptions?.cacheOnly ?? false;
432
+ return {
433
+ queryKey: [
434
+ 'prices',
435
+ 'v3SpotPrices',
436
+ {
437
+ assetIds: [...assetIds].sort(),
438
+ currency,
439
+ includeMarketData,
440
+ cacheOnly,
441
+ },
442
+ ],
443
+ queryFn: async ({ signal, }) => {
444
+ if (assetIds.length === 0) {
445
+ return {};
446
+ }
447
+ return this.fetch(base_client_js_1.API_URLS.PRICES, '/v3/spot-prices', {
448
+ signal,
449
+ params: {
450
+ assetIds,
451
+ vsCurrency: currency,
452
+ includeMarketData,
453
+ cacheOnly,
454
+ },
455
+ });
456
+ },
457
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
458
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
459
+ gcTime: options?.gcTime ?? base_client_js_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));
478
+ }
479
+ // ==========================================================================
480
+ // V1 HISTORICAL PRICES
481
+ // ==========================================================================
482
+ /**
483
+ * Returns the TanStack Query options object for v1 historical prices by coin ID.
484
+ *
485
+ * @param coinId - The CoinGecko coin ID.
486
+ * @param queryOptions - Query options.
487
+ * @param queryOptions.currency - The currency for prices.
488
+ * @param queryOptions.timePeriod - The time period.
489
+ * @param queryOptions.from - Start timestamp.
490
+ * @param queryOptions.to - End timestamp.
491
+ * @param options - Fetch options including cache settings.
492
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
493
+ */
494
+ getV1HistoricalPricesByCoinIdQueryOptions(coinId, queryOptions, options) {
495
+ return {
496
+ queryKey: ['prices', 'v1HistoricalByCoinId', coinId, queryOptions],
497
+ queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.PRICES, `/v1/historical-prices/${coinId}`, {
498
+ signal,
499
+ params: {
500
+ vsCurrency: queryOptions?.currency,
501
+ timePeriod: queryOptions?.timePeriod,
502
+ from: queryOptions?.from,
503
+ to: queryOptions?.to,
504
+ },
505
+ }),
506
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
507
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
508
+ gcTime: options?.gcTime ?? base_client_js_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));
525
+ }
526
+ /**
527
+ * Returns the TanStack Query options object for v1 historical prices by token addresses.
528
+ *
529
+ * @param chainId - The chain ID (hex format).
530
+ * @param tokenAddresses - Array of token addresses.
531
+ * @param queryOptions - Query options.
532
+ * @param queryOptions.currency - The currency for prices.
533
+ * @param queryOptions.timePeriod - The time period.
534
+ * @param queryOptions.from - Start timestamp.
535
+ * @param queryOptions.to - End timestamp.
536
+ * @param options - Fetch options including cache settings.
537
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
538
+ */
539
+ getV1HistoricalPricesByTokenAddressesQueryOptions(chainId, tokenAddresses, queryOptions, options) {
540
+ const chainIdDecimal = parseInt(chainId, 16);
541
+ return {
542
+ queryKey: [
543
+ 'prices',
544
+ 'v1HistoricalByTokenAddresses',
545
+ {
546
+ chainId,
547
+ tokenAddresses: [...tokenAddresses].sort(),
548
+ options: queryOptions,
549
+ },
550
+ ],
551
+ queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/historical-prices`, {
552
+ signal,
553
+ params: {
554
+ tokenAddresses,
555
+ vsCurrency: queryOptions?.currency,
556
+ timePeriod: queryOptions?.timePeriod,
557
+ from: queryOptions?.from,
558
+ to: queryOptions?.to,
559
+ },
560
+ }),
561
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
562
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
563
+ gcTime: options?.gcTime ?? base_client_js_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));
581
+ }
582
+ /**
583
+ * Returns the TanStack Query options object for v1 historical prices.
584
+ *
585
+ * @param chainId - The chain ID (hex format).
586
+ * @param tokenAddress - The token address.
587
+ * @param queryOptions - Query options.
588
+ * @param queryOptions.currency - The currency for prices.
589
+ * @param queryOptions.timeRange - The time range.
590
+ * @param options - Fetch options including cache settings.
591
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
592
+ */
593
+ getV1HistoricalPricesQueryOptions(chainId, tokenAddress, queryOptions, options) {
594
+ const chainIdDecimal = parseInt(chainId, 16);
595
+ const currency = queryOptions?.currency ?? 'usd';
596
+ const timeRange = queryOptions?.timeRange ?? '7d';
597
+ return {
598
+ queryKey: [
599
+ 'prices',
600
+ 'v1Historical',
601
+ chainId,
602
+ tokenAddress,
603
+ currency,
604
+ timeRange,
605
+ ],
606
+ queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/historical-prices/${tokenAddress}`, {
607
+ signal,
608
+ params: {
609
+ vsCurrency: currency,
610
+ timePeriod: timeRange,
611
+ },
612
+ }),
613
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
614
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
615
+ gcTime: options?.gcTime ?? base_client_js_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));
631
+ }
632
+ // ==========================================================================
633
+ // V3 HISTORICAL PRICES
634
+ // ==========================================================================
635
+ /**
636
+ * Returns the TanStack Query options object for v3 historical prices.
637
+ *
638
+ * @param chainId - The CAIP-2 chain ID.
639
+ * @param assetType - The asset type portion of CAIP-19.
640
+ * @param queryOptions - Query options.
641
+ * @param queryOptions.currency - The currency for prices.
642
+ * @param queryOptions.timePeriod - The time period.
643
+ * @param queryOptions.from - Start timestamp.
644
+ * @param queryOptions.to - End timestamp.
645
+ * @param queryOptions.interval - Data interval.
646
+ * @param options - Fetch options including cache settings.
647
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
648
+ */
649
+ getV3HistoricalPricesQueryOptions(chainId, assetType, queryOptions, options) {
650
+ return {
651
+ queryKey: ['prices', 'v3Historical', chainId, assetType, queryOptions],
652
+ queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.PRICES, `/v3/historical-prices/${chainId}/${assetType}`, {
653
+ signal,
654
+ params: {
655
+ vsCurrency: queryOptions?.currency,
656
+ timePeriod: queryOptions?.timePeriod,
657
+ from: queryOptions?.from,
658
+ to: queryOptions?.to,
659
+ interval: queryOptions?.interval,
660
+ },
661
+ }),
662
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
663
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
664
+ gcTime: options?.gcTime ?? base_client_js_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));
683
+ }
684
+ // ==========================================================================
685
+ // V1 HISTORICAL PRICE GRAPH
686
+ // ==========================================================================
687
+ /**
688
+ * Returns the TanStack Query options object for v1 historical price graph by coin ID.
689
+ *
690
+ * @param coinId - The CoinGecko coin ID.
691
+ * @param queryOptions - Query options.
692
+ * @param queryOptions.currency - The currency for prices.
693
+ * @param queryOptions.includeOHLC - Whether to include OHLC data.
694
+ * @param options - Fetch options including cache settings.
695
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
696
+ */
697
+ getV1HistoricalPriceGraphByCoinIdQueryOptions(coinId, queryOptions, options) {
698
+ const currency = queryOptions?.currency ?? 'usd';
699
+ const includeOHLC = queryOptions?.includeOHLC ?? false;
700
+ return {
701
+ queryKey: ['prices', 'v1GraphByCoinId', coinId, currency, includeOHLC],
702
+ queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.PRICES, `/v1/historical-prices-graph/${coinId}`, {
703
+ signal,
704
+ params: {
705
+ vsCurrency: currency,
706
+ includeOHLC,
707
+ },
708
+ }),
709
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
710
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
711
+ gcTime: options?.gcTime ?? base_client_js_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));
726
+ }
727
+ /**
728
+ * Returns the TanStack Query options object for v1 historical price graph by token address.
729
+ *
730
+ * @param chainId - The chain ID (hex format).
731
+ * @param tokenAddress - The token address.
732
+ * @param queryOptions - Query options.
733
+ * @param queryOptions.currency - The currency for prices.
734
+ * @param queryOptions.includeOHLC - Whether to include OHLC data.
735
+ * @param options - Fetch options including cache settings.
736
+ * @returns TanStack Query options for use with useQuery, useSuspenseQuery, etc.
737
+ */
738
+ getV1HistoricalPriceGraphByTokenAddressQueryOptions(chainId, tokenAddress, queryOptions, options) {
739
+ const chainIdDecimal = parseInt(chainId, 16);
740
+ const currency = queryOptions?.currency ?? 'usd';
741
+ const includeOHLC = queryOptions?.includeOHLC ?? false;
742
+ return {
743
+ queryKey: [
744
+ 'prices',
745
+ 'v1GraphByTokenAddress',
746
+ chainId,
747
+ tokenAddress,
748
+ currency,
749
+ includeOHLC,
750
+ ],
751
+ queryFn: ({ signal }) => this.fetch(base_client_js_1.API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/historical-prices-graph/${tokenAddress}`, {
752
+ signal,
753
+ params: {
754
+ vsCurrency: currency,
755
+ includeOHLC,
756
+ },
757
+ }),
758
+ ...(0, shared_types_js_1.getQueryOptionsOverrides)(options),
759
+ staleTime: options?.staleTime ?? base_client_js_1.STALE_TIMES.PRICES,
760
+ gcTime: options?.gcTime ?? base_client_js_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));
776
+ }
777
+ }
778
+ exports.PricesApiClient = PricesApiClient;
779
+ //# sourceMappingURL=client.cjs.map