@surf-ai/sdk 0.1.5-beta → 1.0.0-alpha.0

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.
@@ -1,1092 +0,0 @@
1
- // src/react/utils.ts
2
- import { clsx } from "clsx";
3
- import { twMerge } from "tailwind-merge";
4
- function cn(...inputs) {
5
- return twMerge(clsx(inputs));
6
- }
7
-
8
- // src/react/use-toast.ts
9
- import * as React from "react";
10
- var TOAST_LIMIT = 1;
11
- var TOAST_REMOVE_DELAY = 1e6;
12
- var count = 0;
13
- function genId() {
14
- return (count = (count + 1) % Number.MAX_SAFE_INTEGER).toString();
15
- }
16
- var toastTimeouts = /* @__PURE__ */ new Map();
17
- var listeners = [];
18
- var memoryState = { toasts: [] };
19
- function dispatch(action) {
20
- memoryState = reducer(memoryState, action);
21
- listeners.forEach((l) => l(memoryState));
22
- }
23
- function reducer(state, action) {
24
- switch (action.type) {
25
- case "ADD_TOAST":
26
- return { ...state, toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT) };
27
- case "UPDATE_TOAST":
28
- return { ...state, toasts: state.toasts.map((t) => t.id === action.toast.id ? { ...t, ...action.toast } : t) };
29
- case "DISMISS_TOAST": {
30
- const { toastId } = action;
31
- if (toastId) {
32
- if (!toastTimeouts.has(toastId)) {
33
- toastTimeouts.set(toastId, setTimeout(() => {
34
- toastTimeouts.delete(toastId);
35
- dispatch({ type: "REMOVE_TOAST", toastId });
36
- }, TOAST_REMOVE_DELAY));
37
- }
38
- } else {
39
- state.toasts.forEach((t) => dispatch({ type: "DISMISS_TOAST", toastId: t.id }));
40
- }
41
- return { ...state, toasts: state.toasts.map((t) => t.id === toastId || !toastId ? { ...t } : t) };
42
- }
43
- case "REMOVE_TOAST":
44
- return { ...state, toasts: action.toastId ? state.toasts.filter((t) => t.id !== action.toastId) : [] };
45
- }
46
- }
47
- function toast(props) {
48
- const id = genId();
49
- dispatch({ type: "ADD_TOAST", toast: { ...props, id } });
50
- return { id, dismiss: () => dispatch({ type: "DISMISS_TOAST", toastId: id }), update: (p) => dispatch({ type: "UPDATE_TOAST", toast: { ...p, id } }) };
51
- }
52
- function useToast() {
53
- const [state, setState] = React.useState(memoryState);
54
- React.useEffect(() => {
55
- listeners.push(setState);
56
- return () => {
57
- const i = listeners.indexOf(setState);
58
- if (i > -1) listeners.splice(i, 1);
59
- };
60
- }, []);
61
- return { ...state, toast, dismiss: (toastId) => dispatch({ type: "DISMISS_TOAST", toastId }) };
62
- }
63
-
64
- // src/react/hooks/exchange.ts
65
- import { useQuery } from "@tanstack/react-query";
66
-
67
- // src/react/fetch.ts
68
- var BASE = typeof window !== "undefined" ? (import.meta.env?.BASE_URL || "/").replace(/\/$/, "") : "";
69
- function normalizePath(path) {
70
- return String(path || "").replace(/^\/+/, "").replace(/^(?:proxy\/)+/, "");
71
- }
72
- async function fetchWithRetry(url, init, retries = 1) {
73
- for (let attempt = 0; attempt <= retries; attempt++) {
74
- const res = await fetch(url, init);
75
- if (!res.ok) {
76
- const text2 = await res.text();
77
- throw new Error(`API error ${res.status}: ${text2.slice(0, 200)}`);
78
- }
79
- const text = await res.text();
80
- if (text) return JSON.parse(text);
81
- if (attempt < retries) await new Promise((r) => setTimeout(r, 1e3));
82
- }
83
- throw new Error(`Empty response from ${url}`);
84
- }
85
- async function proxyGet(path, params) {
86
- const cleaned = {};
87
- if (params) {
88
- for (const [k, v] of Object.entries(params)) {
89
- if (v != null) cleaned[k] = String(v);
90
- }
91
- }
92
- const qs = Object.keys(cleaned).length ? "?" + new URLSearchParams(cleaned).toString() : "";
93
- return fetchWithRetry(`${BASE}/proxy/${normalizePath(path)}${qs}`);
94
- }
95
-
96
- // src/react/hooks/exchange.ts
97
- function useExchangeDepth(params) {
98
- return useQuery({
99
- queryKey: ["exchange-depth", params],
100
- queryFn: () => proxyGet("exchange/depth", params)
101
- });
102
- }
103
- function useExchangeFundingHistory(params) {
104
- return useQuery({
105
- queryKey: ["exchange-funding-history", params],
106
- queryFn: () => proxyGet("exchange/funding-history", params)
107
- });
108
- }
109
- function useExchangeKlines(params) {
110
- return useQuery({
111
- queryKey: ["exchange-klines", params],
112
- queryFn: () => proxyGet("exchange/klines", params)
113
- });
114
- }
115
- function useExchangeLongShortRatio(params) {
116
- return useQuery({
117
- queryKey: ["exchange-long-short-ratio", params],
118
- queryFn: () => proxyGet("exchange/long-short-ratio", params)
119
- });
120
- }
121
- function useExchangeMarkets(params) {
122
- return useQuery({
123
- queryKey: ["exchange-markets", params],
124
- queryFn: () => proxyGet("exchange/markets", params)
125
- });
126
- }
127
- function useExchangePerp(params) {
128
- return useQuery({
129
- queryKey: ["exchange-perp", params],
130
- queryFn: () => proxyGet("exchange/perp", params)
131
- });
132
- }
133
- function useExchangePrice(params) {
134
- return useQuery({
135
- queryKey: ["exchange-price", params],
136
- queryFn: () => proxyGet("exchange/price", params)
137
- });
138
- }
139
-
140
- // src/react/hooks/fund.ts
141
- import { useQuery as useQuery2, useInfiniteQuery as useInfiniteQuery2 } from "@tanstack/react-query";
142
- function useFundDetail(params) {
143
- return useQuery2({
144
- queryKey: ["fund-detail", params],
145
- queryFn: () => proxyGet("fund/detail", params)
146
- });
147
- }
148
- function useInfiniteFundPortfolio(params) {
149
- return useInfiniteQuery2({
150
- queryKey: ["fund-portfolio", params],
151
- queryFn: ({ pageParam = 0 }) => proxyGet("fund/portfolio", { ...params, offset: String(pageParam) }),
152
- initialPageParam: 0,
153
- getNextPageParam: (last) => {
154
- const m = last?.meta;
155
- if (!m?.total || !m?.limit) return void 0;
156
- const next = (m.offset ?? 0) + m.limit;
157
- return next < m.total ? next : void 0;
158
- }
159
- });
160
- }
161
- function useInfiniteFundRanking(params) {
162
- return useInfiniteQuery2({
163
- queryKey: ["fund-ranking", params],
164
- queryFn: ({ pageParam = 0 }) => proxyGet("fund/ranking", { ...params, offset: String(pageParam) }),
165
- initialPageParam: 0,
166
- getNextPageParam: (last) => {
167
- const m = last?.meta;
168
- if (!m?.total || !m?.limit) return void 0;
169
- const next = (m.offset ?? 0) + m.limit;
170
- return next < m.total ? next : void 0;
171
- }
172
- });
173
- }
174
-
175
- // src/react/hooks/kalshi.ts
176
- import { useInfiniteQuery as useInfiniteQuery3 } from "@tanstack/react-query";
177
- function useInfiniteKalshiEvents(params) {
178
- return useInfiniteQuery3({
179
- queryKey: ["kalshi-events", params],
180
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/kalshi/events", { ...params, offset: String(pageParam) }),
181
- initialPageParam: 0,
182
- getNextPageParam: (last) => {
183
- const m = last?.meta;
184
- if (!m?.total || !m?.limit) return void 0;
185
- const next = (m.offset ?? 0) + m.limit;
186
- return next < m.total ? next : void 0;
187
- }
188
- });
189
- }
190
- function useInfiniteKalshiMarkets(params) {
191
- return useInfiniteQuery3({
192
- queryKey: ["kalshi-markets", params],
193
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/kalshi/markets", { ...params, offset: String(pageParam) }),
194
- initialPageParam: 0,
195
- getNextPageParam: (last) => {
196
- const m = last?.meta;
197
- if (!m?.total || !m?.limit) return void 0;
198
- const next = (m.offset ?? 0) + m.limit;
199
- return next < m.total ? next : void 0;
200
- }
201
- });
202
- }
203
- function useInfiniteKalshiOpenInterest(params) {
204
- return useInfiniteQuery3({
205
- queryKey: ["kalshi-open-interest", params],
206
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/kalshi/open-interest", { ...params, offset: String(pageParam) }),
207
- initialPageParam: 0,
208
- getNextPageParam: (last) => {
209
- const m = last?.meta;
210
- if (!m?.total || !m?.limit) return void 0;
211
- const next = (m.offset ?? 0) + m.limit;
212
- return next < m.total ? next : void 0;
213
- }
214
- });
215
- }
216
- function useInfiniteKalshiPrices(params) {
217
- return useInfiniteQuery3({
218
- queryKey: ["kalshi-prices", params],
219
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/kalshi/prices", { ...params, offset: String(pageParam) }),
220
- initialPageParam: 0,
221
- getNextPageParam: (last) => {
222
- const m = last?.meta;
223
- if (!m?.total || !m?.limit) return void 0;
224
- const next = (m.offset ?? 0) + m.limit;
225
- return next < m.total ? next : void 0;
226
- }
227
- });
228
- }
229
- function useInfiniteKalshiRanking(params) {
230
- return useInfiniteQuery3({
231
- queryKey: ["kalshi-ranking", params],
232
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/kalshi/ranking", { ...params, offset: String(pageParam) }),
233
- initialPageParam: 0,
234
- getNextPageParam: (last) => {
235
- const m = last?.meta;
236
- if (!m?.total || !m?.limit) return void 0;
237
- const next = (m.offset ?? 0) + m.limit;
238
- return next < m.total ? next : void 0;
239
- }
240
- });
241
- }
242
- function useInfiniteKalshiTrades(params) {
243
- return useInfiniteQuery3({
244
- queryKey: ["kalshi-trades", params],
245
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/kalshi/trades", { ...params, offset: String(pageParam) }),
246
- initialPageParam: 0,
247
- getNextPageParam: (last) => {
248
- const m = last?.meta;
249
- if (!m?.total || !m?.limit) return void 0;
250
- const next = (m.offset ?? 0) + m.limit;
251
- return next < m.total ? next : void 0;
252
- }
253
- });
254
- }
255
- function useInfiniteKalshiVolumes(params) {
256
- return useInfiniteQuery3({
257
- queryKey: ["kalshi-volumes", params],
258
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/kalshi/volumes", { ...params, offset: String(pageParam) }),
259
- initialPageParam: 0,
260
- getNextPageParam: (last) => {
261
- const m = last?.meta;
262
- if (!m?.total || !m?.limit) return void 0;
263
- const next = (m.offset ?? 0) + m.limit;
264
- return next < m.total ? next : void 0;
265
- }
266
- });
267
- }
268
-
269
- // src/react/hooks/market.ts
270
- import { useQuery as useQuery4, useInfiniteQuery as useInfiniteQuery4 } from "@tanstack/react-query";
271
- function useMarketEtf(params) {
272
- return useQuery4({
273
- queryKey: ["market-etf", params],
274
- queryFn: () => proxyGet("market/etf", params)
275
- });
276
- }
277
- function useMarketFearGreed(params) {
278
- return useQuery4({
279
- queryKey: ["market-fear-greed", params],
280
- queryFn: () => proxyGet("market/fear-greed", params)
281
- });
282
- }
283
- function useMarketFutures(params) {
284
- return useQuery4({
285
- queryKey: ["market-futures", params],
286
- queryFn: () => proxyGet("market/futures", params)
287
- });
288
- }
289
- function useMarketLiquidationChart(params) {
290
- return useQuery4({
291
- queryKey: ["market-liquidation-chart", params],
292
- queryFn: () => proxyGet("market/liquidation/chart", params)
293
- });
294
- }
295
- function useMarketLiquidationExchangeList(params) {
296
- return useQuery4({
297
- queryKey: ["market-liquidation-exchange-list", params],
298
- queryFn: () => proxyGet("market/liquidation/exchange-list", params)
299
- });
300
- }
301
- function useMarketLiquidationOrder(params) {
302
- return useQuery4({
303
- queryKey: ["market-liquidation-order", params],
304
- queryFn: () => proxyGet("market/liquidation/order", params)
305
- });
306
- }
307
- function useMarketOnchainIndicator(params) {
308
- return useQuery4({
309
- queryKey: ["market-onchain-indicator", params],
310
- queryFn: () => proxyGet("market/onchain-indicator", params)
311
- });
312
- }
313
- function useMarketOptions(params) {
314
- return useQuery4({
315
- queryKey: ["market-options", params],
316
- queryFn: () => proxyGet("market/options", params)
317
- });
318
- }
319
- function useMarketPrice(params) {
320
- return useQuery4({
321
- queryKey: ["market-price", params],
322
- queryFn: () => proxyGet("market/price", params)
323
- });
324
- }
325
- function useMarketPriceIndicator(params) {
326
- return useQuery4({
327
- queryKey: ["market-price-indicator", params],
328
- queryFn: () => proxyGet("market/price-indicator", params)
329
- });
330
- }
331
- function useInfiniteMarketRanking(params) {
332
- return useInfiniteQuery4({
333
- queryKey: ["market-ranking", params],
334
- queryFn: ({ pageParam = 0 }) => proxyGet("market/ranking", { ...params, offset: String(pageParam) }),
335
- initialPageParam: 0,
336
- getNextPageParam: (last) => {
337
- const m = last?.meta;
338
- if (!m?.total || !m?.limit) return void 0;
339
- const next = (m.offset ?? 0) + m.limit;
340
- return next < m.total ? next : void 0;
341
- }
342
- });
343
- }
344
-
345
- // src/react/hooks/news.ts
346
- import { useQuery as useQuery5, useInfiniteQuery as useInfiniteQuery5 } from "@tanstack/react-query";
347
- function useNewsDetail(params) {
348
- return useQuery5({
349
- queryKey: ["news-detail", params],
350
- queryFn: () => proxyGet("news/detail", params)
351
- });
352
- }
353
- function useInfiniteNewsFeed(params) {
354
- return useInfiniteQuery5({
355
- queryKey: ["news-feed", params],
356
- queryFn: ({ pageParam = 0 }) => proxyGet("news/feed", { ...params, offset: String(pageParam) }),
357
- initialPageParam: 0,
358
- getNextPageParam: (last) => {
359
- const m = last?.meta;
360
- if (!m?.total || !m?.limit) return void 0;
361
- const next = (m.offset ?? 0) + m.limit;
362
- return next < m.total ? next : void 0;
363
- }
364
- });
365
- }
366
-
367
- // src/react/hooks/onchain.ts
368
- import { useQuery as useQuery6, useInfiniteQuery as useInfiniteQuery6 } from "@tanstack/react-query";
369
- function useInfiniteOnchainBridgeRanking(params) {
370
- return useInfiniteQuery6({
371
- queryKey: ["onchain-bridge-ranking", params],
372
- queryFn: ({ pageParam = 0 }) => proxyGet("onchain/bridge/ranking", { ...params, offset: String(pageParam) }),
373
- initialPageParam: 0,
374
- getNextPageParam: (last) => {
375
- const m = last?.meta;
376
- if (!m?.total || !m?.limit) return void 0;
377
- const next = (m.offset ?? 0) + m.limit;
378
- return next < m.total ? next : void 0;
379
- }
380
- });
381
- }
382
- function useOnchainGasPrice(params) {
383
- return useQuery6({
384
- queryKey: ["onchain-gas-price", params],
385
- queryFn: () => proxyGet("onchain/gas-price", params)
386
- });
387
- }
388
- function useInfiniteOnchainStructuredQuery(params) {
389
- return useInfiniteQuery6({
390
- queryKey: ["onchain-structured-query", params],
391
- queryFn: ({ pageParam = 0 }) => proxyGet("onchain/query", { ...params, offset: String(pageParam) }),
392
- initialPageParam: 0,
393
- getNextPageParam: (last) => {
394
- const m = last?.meta;
395
- if (!m?.total || !m?.limit) return void 0;
396
- const next = (m.offset ?? 0) + m.limit;
397
- return next < m.total ? next : void 0;
398
- }
399
- });
400
- }
401
- function useInfiniteOnchainSchema() {
402
- return useInfiniteQuery6({
403
- queryKey: ["onchain-schema"],
404
- queryFn: () => proxyGet("onchain/schema"),
405
- initialPageParam: 0,
406
- getNextPageParam: (last) => {
407
- const m = last?.meta;
408
- if (!m?.total || !m?.limit) return void 0;
409
- const next = (m.offset ?? 0) + m.limit;
410
- return next < m.total ? next : void 0;
411
- }
412
- });
413
- }
414
- function useInfiniteOnchainSql(params) {
415
- return useInfiniteQuery6({
416
- queryKey: ["onchain-sql", params],
417
- queryFn: ({ pageParam = 0 }) => proxyGet("onchain/sql", { ...params, offset: String(pageParam) }),
418
- initialPageParam: 0,
419
- getNextPageParam: (last) => {
420
- const m = last?.meta;
421
- if (!m?.total || !m?.limit) return void 0;
422
- const next = (m.offset ?? 0) + m.limit;
423
- return next < m.total ? next : void 0;
424
- }
425
- });
426
- }
427
- function useInfiniteOnchainTx(params) {
428
- return useInfiniteQuery6({
429
- queryKey: ["onchain-tx", params],
430
- queryFn: ({ pageParam = 0 }) => proxyGet("onchain/tx", { ...params, offset: String(pageParam) }),
431
- initialPageParam: 0,
432
- getNextPageParam: (last) => {
433
- const m = last?.meta;
434
- if (!m?.total || !m?.limit) return void 0;
435
- const next = (m.offset ?? 0) + m.limit;
436
- return next < m.total ? next : void 0;
437
- }
438
- });
439
- }
440
- function useInfiniteOnchainYieldRanking(params) {
441
- return useInfiniteQuery6({
442
- queryKey: ["onchain-yield-ranking", params],
443
- queryFn: ({ pageParam = 0 }) => proxyGet("onchain/yield/ranking", { ...params, offset: String(pageParam) }),
444
- initialPageParam: 0,
445
- getNextPageParam: (last) => {
446
- const m = last?.meta;
447
- if (!m?.total || !m?.limit) return void 0;
448
- const next = (m.offset ?? 0) + m.limit;
449
- return next < m.total ? next : void 0;
450
- }
451
- });
452
- }
453
-
454
- // src/react/hooks/polymarket.ts
455
- import { useInfiniteQuery as useInfiniteQuery7 } from "@tanstack/react-query";
456
- function useInfinitePolymarketActivity(params) {
457
- return useInfiniteQuery7({
458
- queryKey: ["polymarket-activity", params],
459
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/polymarket/activity", { ...params, offset: String(pageParam) }),
460
- initialPageParam: 0,
461
- getNextPageParam: (last) => {
462
- const m = last?.meta;
463
- if (!m?.total || !m?.limit) return void 0;
464
- const next = (m.offset ?? 0) + m.limit;
465
- return next < m.total ? next : void 0;
466
- }
467
- });
468
- }
469
- function useInfinitePolymarketEvents(params) {
470
- return useInfiniteQuery7({
471
- queryKey: ["polymarket-events", params],
472
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/polymarket/events", { ...params, offset: String(pageParam) }),
473
- initialPageParam: 0,
474
- getNextPageParam: (last) => {
475
- const m = last?.meta;
476
- if (!m?.total || !m?.limit) return void 0;
477
- const next = (m.offset ?? 0) + m.limit;
478
- return next < m.total ? next : void 0;
479
- }
480
- });
481
- }
482
- function useInfinitePolymarketMarkets(params) {
483
- return useInfiniteQuery7({
484
- queryKey: ["polymarket-markets", params],
485
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/polymarket/markets", { ...params, offset: String(pageParam) }),
486
- initialPageParam: 0,
487
- getNextPageParam: (last) => {
488
- const m = last?.meta;
489
- if (!m?.total || !m?.limit) return void 0;
490
- const next = (m.offset ?? 0) + m.limit;
491
- return next < m.total ? next : void 0;
492
- }
493
- });
494
- }
495
- function useInfinitePolymarketOpenInterest(params) {
496
- return useInfiniteQuery7({
497
- queryKey: ["polymarket-open-interest", params],
498
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/polymarket/open-interest", { ...params, offset: String(pageParam) }),
499
- initialPageParam: 0,
500
- getNextPageParam: (last) => {
501
- const m = last?.meta;
502
- if (!m?.total || !m?.limit) return void 0;
503
- const next = (m.offset ?? 0) + m.limit;
504
- return next < m.total ? next : void 0;
505
- }
506
- });
507
- }
508
- function useInfinitePolymarketPositions(params) {
509
- return useInfiniteQuery7({
510
- queryKey: ["polymarket-positions", params],
511
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/polymarket/positions", { ...params, offset: String(pageParam) }),
512
- initialPageParam: 0,
513
- getNextPageParam: (last) => {
514
- const m = last?.meta;
515
- if (!m?.total || !m?.limit) return void 0;
516
- const next = (m.offset ?? 0) + m.limit;
517
- return next < m.total ? next : void 0;
518
- }
519
- });
520
- }
521
- function useInfinitePolymarketPrices(params) {
522
- return useInfiniteQuery7({
523
- queryKey: ["polymarket-prices", params],
524
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/polymarket/prices", { ...params, offset: String(pageParam) }),
525
- initialPageParam: 0,
526
- getNextPageParam: (last) => {
527
- const m = last?.meta;
528
- if (!m?.total || !m?.limit) return void 0;
529
- const next = (m.offset ?? 0) + m.limit;
530
- return next < m.total ? next : void 0;
531
- }
532
- });
533
- }
534
- function useInfinitePolymarketRanking(params) {
535
- return useInfiniteQuery7({
536
- queryKey: ["polymarket-ranking", params],
537
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/polymarket/ranking", { ...params, offset: String(pageParam) }),
538
- initialPageParam: 0,
539
- getNextPageParam: (last) => {
540
- const m = last?.meta;
541
- if (!m?.total || !m?.limit) return void 0;
542
- const next = (m.offset ?? 0) + m.limit;
543
- return next < m.total ? next : void 0;
544
- }
545
- });
546
- }
547
- function useInfinitePolymarketTrades(params) {
548
- return useInfiniteQuery7({
549
- queryKey: ["polymarket-trades", params],
550
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/polymarket/trades", { ...params, offset: String(pageParam) }),
551
- initialPageParam: 0,
552
- getNextPageParam: (last) => {
553
- const m = last?.meta;
554
- if (!m?.total || !m?.limit) return void 0;
555
- const next = (m.offset ?? 0) + m.limit;
556
- return next < m.total ? next : void 0;
557
- }
558
- });
559
- }
560
- function useInfinitePolymarketVolumes(params) {
561
- return useInfiniteQuery7({
562
- queryKey: ["polymarket-volumes", params],
563
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/polymarket/volumes", { ...params, offset: String(pageParam) }),
564
- initialPageParam: 0,
565
- getNextPageParam: (last) => {
566
- const m = last?.meta;
567
- if (!m?.total || !m?.limit) return void 0;
568
- const next = (m.offset ?? 0) + m.limit;
569
- return next < m.total ? next : void 0;
570
- }
571
- });
572
- }
573
-
574
- // src/react/hooks/prediction_market.ts
575
- import { useInfiniteQuery as useInfiniteQuery8 } from "@tanstack/react-query";
576
- function useInfinitePredictionMarketCategoryMetrics(params) {
577
- return useInfiniteQuery8({
578
- queryKey: ["prediction-market-category-metrics", params],
579
- queryFn: ({ pageParam = 0 }) => proxyGet("prediction-market/category-metrics", { ...params, offset: String(pageParam) }),
580
- initialPageParam: 0,
581
- getNextPageParam: (last) => {
582
- const m = last?.meta;
583
- if (!m?.total || !m?.limit) return void 0;
584
- const next = (m.offset ?? 0) + m.limit;
585
- return next < m.total ? next : void 0;
586
- }
587
- });
588
- }
589
-
590
- // src/react/hooks/project.ts
591
- import { useQuery as useQuery9, useInfiniteQuery as useInfiniteQuery9 } from "@tanstack/react-query";
592
- function useInfiniteProjectDefiMetrics(params) {
593
- return useInfiniteQuery9({
594
- queryKey: ["project-defi-metrics", params],
595
- queryFn: ({ pageParam = 0 }) => proxyGet("project/defi/metrics", { ...params, offset: String(pageParam) }),
596
- initialPageParam: 0,
597
- getNextPageParam: (last) => {
598
- const m = last?.meta;
599
- if (!m?.total || !m?.limit) return void 0;
600
- const next = (m.offset ?? 0) + m.limit;
601
- return next < m.total ? next : void 0;
602
- }
603
- });
604
- }
605
- function useInfiniteProjectDefiRanking(params) {
606
- return useInfiniteQuery9({
607
- queryKey: ["project-defi-ranking", params],
608
- queryFn: ({ pageParam = 0 }) => proxyGet("project/defi/ranking", { ...params, offset: String(pageParam) }),
609
- initialPageParam: 0,
610
- getNextPageParam: (last) => {
611
- const m = last?.meta;
612
- if (!m?.total || !m?.limit) return void 0;
613
- const next = (m.offset ?? 0) + m.limit;
614
- return next < m.total ? next : void 0;
615
- }
616
- });
617
- }
618
- function useProjectDetail(params) {
619
- return useQuery9({
620
- queryKey: ["project-detail", params],
621
- queryFn: () => proxyGet("project/detail", params)
622
- });
623
- }
624
-
625
- // src/react/hooks/search.ts
626
- import { useInfiniteQuery as useInfiniteQuery10 } from "@tanstack/react-query";
627
- function useInfiniteSearchAirdrop(params) {
628
- return useInfiniteQuery10({
629
- queryKey: ["search-airdrop", params],
630
- queryFn: ({ pageParam = 0 }) => proxyGet("search/airdrop", { ...params, offset: String(pageParam) }),
631
- initialPageParam: 0,
632
- getNextPageParam: (last) => {
633
- const m = last?.meta;
634
- if (!m?.total || !m?.limit) return void 0;
635
- const next = (m.offset ?? 0) + m.limit;
636
- return next < m.total ? next : void 0;
637
- }
638
- });
639
- }
640
- function useInfiniteSearchEvents(params) {
641
- return useInfiniteQuery10({
642
- queryKey: ["search-events", params],
643
- queryFn: ({ pageParam = 0 }) => proxyGet("search/events", { ...params, offset: String(pageParam) }),
644
- initialPageParam: 0,
645
- getNextPageParam: (last) => {
646
- const m = last?.meta;
647
- if (!m?.total || !m?.limit) return void 0;
648
- const next = (m.offset ?? 0) + m.limit;
649
- return next < m.total ? next : void 0;
650
- }
651
- });
652
- }
653
- function useInfiniteSearchFund(params) {
654
- return useInfiniteQuery10({
655
- queryKey: ["search-fund", params],
656
- queryFn: ({ pageParam = 0 }) => proxyGet("search/fund", { ...params, offset: String(pageParam) }),
657
- initialPageParam: 0,
658
- getNextPageParam: (last) => {
659
- const m = last?.meta;
660
- if (!m?.total || !m?.limit) return void 0;
661
- const next = (m.offset ?? 0) + m.limit;
662
- return next < m.total ? next : void 0;
663
- }
664
- });
665
- }
666
- function useInfiniteSearchKalshi(params) {
667
- return useInfiniteQuery10({
668
- queryKey: ["search-kalshi", params],
669
- queryFn: ({ pageParam = 0 }) => proxyGet("search/kalshi", { ...params, offset: String(pageParam) }),
670
- initialPageParam: 0,
671
- getNextPageParam: (last) => {
672
- const m = last?.meta;
673
- if (!m?.total || !m?.limit) return void 0;
674
- const next = (m.offset ?? 0) + m.limit;
675
- return next < m.total ? next : void 0;
676
- }
677
- });
678
- }
679
- function useInfiniteSearchNews(params) {
680
- return useInfiniteQuery10({
681
- queryKey: ["search-news", params],
682
- queryFn: ({ pageParam = 0 }) => proxyGet("search/news", { ...params, offset: String(pageParam) }),
683
- initialPageParam: 0,
684
- getNextPageParam: (last) => {
685
- const m = last?.meta;
686
- if (!m?.total || !m?.limit) return void 0;
687
- const next = (m.offset ?? 0) + m.limit;
688
- return next < m.total ? next : void 0;
689
- }
690
- });
691
- }
692
- function useInfiniteSearchPolymarket(params) {
693
- return useInfiniteQuery10({
694
- queryKey: ["search-polymarket", params],
695
- queryFn: ({ pageParam = 0 }) => proxyGet("search/polymarket", { ...params, offset: String(pageParam) }),
696
- initialPageParam: 0,
697
- getNextPageParam: (last) => {
698
- const m = last?.meta;
699
- if (!m?.total || !m?.limit) return void 0;
700
- const next = (m.offset ?? 0) + m.limit;
701
- return next < m.total ? next : void 0;
702
- }
703
- });
704
- }
705
- function useInfiniteSearchProject(params) {
706
- return useInfiniteQuery10({
707
- queryKey: ["search-project", params],
708
- queryFn: ({ pageParam = 0 }) => proxyGet("search/project", { ...params, offset: String(pageParam) }),
709
- initialPageParam: 0,
710
- getNextPageParam: (last) => {
711
- const m = last?.meta;
712
- if (!m?.total || !m?.limit) return void 0;
713
- const next = (m.offset ?? 0) + m.limit;
714
- return next < m.total ? next : void 0;
715
- }
716
- });
717
- }
718
- function useInfiniteSearchSocialPeople(params) {
719
- return useInfiniteQuery10({
720
- queryKey: ["search-social-people", params],
721
- queryFn: ({ pageParam }) => proxyGet("search/social/people", { ...params, cursor: pageParam || void 0 }),
722
- initialPageParam: "",
723
- getNextPageParam: (last) => last?.meta?.has_more ? last.meta.next_cursor : void 0
724
- });
725
- }
726
- function useInfiniteSearchSocialPosts(params) {
727
- return useInfiniteQuery10({
728
- queryKey: ["search-social-posts", params],
729
- queryFn: ({ pageParam }) => proxyGet("search/social/posts", { ...params, cursor: pageParam || void 0 }),
730
- initialPageParam: "",
731
- getNextPageParam: (last) => last?.meta?.has_more ? last.meta.next_cursor : void 0
732
- });
733
- }
734
- function useInfiniteSearchWallet(params) {
735
- return useInfiniteQuery10({
736
- queryKey: ["search-wallet", params],
737
- queryFn: ({ pageParam = 0 }) => proxyGet("search/wallet", { ...params, offset: String(pageParam) }),
738
- initialPageParam: 0,
739
- getNextPageParam: (last) => {
740
- const m = last?.meta;
741
- if (!m?.total || !m?.limit) return void 0;
742
- const next = (m.offset ?? 0) + m.limit;
743
- return next < m.total ? next : void 0;
744
- }
745
- });
746
- }
747
- function useInfiniteSearchWeb(params) {
748
- return useInfiniteQuery10({
749
- queryKey: ["search-web", params],
750
- queryFn: ({ pageParam = 0 }) => proxyGet("search/web", { ...params, offset: String(pageParam) }),
751
- initialPageParam: 0,
752
- getNextPageParam: (last) => {
753
- const m = last?.meta;
754
- if (!m?.total || !m?.limit) return void 0;
755
- const next = (m.offset ?? 0) + m.limit;
756
- return next < m.total ? next : void 0;
757
- }
758
- });
759
- }
760
-
761
- // src/react/hooks/social.ts
762
- import { useQuery as useQuery11, useInfiniteQuery as useInfiniteQuery11 } from "@tanstack/react-query";
763
- function useSocialDetail(params) {
764
- return useQuery11({
765
- queryKey: ["social-detail", params],
766
- queryFn: () => proxyGet("social/detail", params)
767
- });
768
- }
769
- function useInfiniteSocialMindshare(params) {
770
- return useInfiniteQuery11({
771
- queryKey: ["social-mindshare", params],
772
- queryFn: ({ pageParam = 0 }) => proxyGet("social/mindshare", { ...params, offset: String(pageParam) }),
773
- initialPageParam: 0,
774
- getNextPageParam: (last) => {
775
- const m = last?.meta;
776
- if (!m?.total || !m?.limit) return void 0;
777
- const next = (m.offset ?? 0) + m.limit;
778
- return next < m.total ? next : void 0;
779
- }
780
- });
781
- }
782
- function useInfiniteSocialRanking(params) {
783
- return useInfiniteQuery11({
784
- queryKey: ["social-ranking", params],
785
- queryFn: ({ pageParam = 0 }) => proxyGet("social/ranking", { ...params, offset: String(pageParam) }),
786
- initialPageParam: 0,
787
- getNextPageParam: (last) => {
788
- const m = last?.meta;
789
- if (!m?.total || !m?.limit) return void 0;
790
- const next = (m.offset ?? 0) + m.limit;
791
- return next < m.total ? next : void 0;
792
- }
793
- });
794
- }
795
- function useInfiniteSocialSmartFollowersHistory(params) {
796
- return useInfiniteQuery11({
797
- queryKey: ["social-smart-followers-history", params],
798
- queryFn: ({ pageParam = 0 }) => proxyGet("social/smart-followers/history", { ...params, offset: String(pageParam) }),
799
- initialPageParam: 0,
800
- getNextPageParam: (last) => {
801
- const m = last?.meta;
802
- if (!m?.total || !m?.limit) return void 0;
803
- const next = (m.offset ?? 0) + m.limit;
804
- return next < m.total ? next : void 0;
805
- }
806
- });
807
- }
808
- function useInfiniteSocialTweetReplies(params) {
809
- return useInfiniteQuery11({
810
- queryKey: ["social-tweet-replies", params],
811
- queryFn: ({ pageParam }) => proxyGet("social/tweet/replies", { ...params, cursor: pageParam || void 0 }),
812
- initialPageParam: "",
813
- getNextPageParam: (last) => last?.meta?.has_more ? last.meta.next_cursor : void 0
814
- });
815
- }
816
- function useInfiniteSocialTweets(params) {
817
- return useInfiniteQuery11({
818
- queryKey: ["social-tweets", params],
819
- queryFn: ({ pageParam = 0 }) => proxyGet("social/tweets", { ...params, offset: String(pageParam) }),
820
- initialPageParam: 0,
821
- getNextPageParam: (last) => {
822
- const m = last?.meta;
823
- if (!m?.total || !m?.limit) return void 0;
824
- const next = (m.offset ?? 0) + m.limit;
825
- return next < m.total ? next : void 0;
826
- }
827
- });
828
- }
829
- function useSocialUser(params) {
830
- return useQuery11({
831
- queryKey: ["social-user", params],
832
- queryFn: () => proxyGet("social/user", params)
833
- });
834
- }
835
- function useInfiniteSocialUserFollowers(params) {
836
- return useInfiniteQuery11({
837
- queryKey: ["social-user-followers", params],
838
- queryFn: ({ pageParam }) => proxyGet("social/user/followers", { ...params, cursor: pageParam || void 0 }),
839
- initialPageParam: "",
840
- getNextPageParam: (last) => last?.meta?.has_more ? last.meta.next_cursor : void 0
841
- });
842
- }
843
- function useInfiniteSocialUserFollowing(params) {
844
- return useInfiniteQuery11({
845
- queryKey: ["social-user-following", params],
846
- queryFn: ({ pageParam }) => proxyGet("social/user/following", { ...params, cursor: pageParam || void 0 }),
847
- initialPageParam: "",
848
- getNextPageParam: (last) => last?.meta?.has_more ? last.meta.next_cursor : void 0
849
- });
850
- }
851
- function useInfiniteSocialUserPosts(params) {
852
- return useInfiniteQuery11({
853
- queryKey: ["social-user-posts", params],
854
- queryFn: ({ pageParam }) => proxyGet("social/user/posts", { ...params, cursor: pageParam || void 0 }),
855
- initialPageParam: "",
856
- getNextPageParam: (last) => last?.meta?.has_more ? last.meta.next_cursor : void 0
857
- });
858
- }
859
- function useInfiniteSocialUserReplies(params) {
860
- return useInfiniteQuery11({
861
- queryKey: ["social-user-replies", params],
862
- queryFn: ({ pageParam }) => proxyGet("social/user/replies", { ...params, cursor: pageParam || void 0 }),
863
- initialPageParam: "",
864
- getNextPageParam: (last) => last?.meta?.has_more ? last.meta.next_cursor : void 0
865
- });
866
- }
867
-
868
- // src/react/hooks/token.ts
869
- import { useInfiniteQuery as useInfiniteQuery12 } from "@tanstack/react-query";
870
- function useInfiniteTokenDexTrades(params) {
871
- return useInfiniteQuery12({
872
- queryKey: ["token-dex-trades", params],
873
- queryFn: ({ pageParam = 0 }) => proxyGet("token/dex-trades", { ...params, offset: String(pageParam) }),
874
- initialPageParam: 0,
875
- getNextPageParam: (last) => {
876
- const m = last?.meta;
877
- if (!m?.total || !m?.limit) return void 0;
878
- const next = (m.offset ?? 0) + m.limit;
879
- return next < m.total ? next : void 0;
880
- }
881
- });
882
- }
883
- function useInfiniteTokenHolders(params) {
884
- return useInfiniteQuery12({
885
- queryKey: ["token-holders", params],
886
- queryFn: ({ pageParam = 0 }) => proxyGet("token/holders", { ...params, offset: String(pageParam) }),
887
- initialPageParam: 0,
888
- getNextPageParam: (last) => {
889
- const m = last?.meta;
890
- if (!m?.total || !m?.limit) return void 0;
891
- const next = (m.offset ?? 0) + m.limit;
892
- return next < m.total ? next : void 0;
893
- }
894
- });
895
- }
896
- function useInfiniteTokenTokenomics(params) {
897
- return useInfiniteQuery12({
898
- queryKey: ["token-tokenomics", params],
899
- queryFn: ({ pageParam = 0 }) => proxyGet("token/tokenomics", { ...params, offset: String(pageParam) }),
900
- initialPageParam: 0,
901
- getNextPageParam: (last) => {
902
- const m = last?.meta;
903
- if (!m?.total || !m?.limit) return void 0;
904
- const next = (m.offset ?? 0) + m.limit;
905
- return next < m.total ? next : void 0;
906
- }
907
- });
908
- }
909
- function useInfiniteTokenTransfers(params) {
910
- return useInfiniteQuery12({
911
- queryKey: ["token-transfers", params],
912
- queryFn: ({ pageParam = 0 }) => proxyGet("token/transfers", { ...params, offset: String(pageParam) }),
913
- initialPageParam: 0,
914
- getNextPageParam: (last) => {
915
- const m = last?.meta;
916
- if (!m?.total || !m?.limit) return void 0;
917
- const next = (m.offset ?? 0) + m.limit;
918
- return next < m.total ? next : void 0;
919
- }
920
- });
921
- }
922
-
923
- // src/react/hooks/wallet.ts
924
- import { useQuery as useQuery13, useInfiniteQuery as useInfiniteQuery13 } from "@tanstack/react-query";
925
- function useWalletDetail(params) {
926
- return useQuery13({
927
- queryKey: ["wallet-detail", params],
928
- queryFn: () => proxyGet("wallet/detail", params)
929
- });
930
- }
931
- function useInfiniteWalletHistory(params) {
932
- return useInfiniteQuery13({
933
- queryKey: ["wallet-history", params],
934
- queryFn: ({ pageParam = 0 }) => proxyGet("wallet/history", { ...params, offset: String(pageParam) }),
935
- initialPageParam: 0,
936
- getNextPageParam: (last) => {
937
- const m = last?.meta;
938
- if (!m?.total || !m?.limit) return void 0;
939
- const next = (m.offset ?? 0) + m.limit;
940
- return next < m.total ? next : void 0;
941
- }
942
- });
943
- }
944
- function useInfiniteWalletLabelsBatch(params) {
945
- return useInfiniteQuery13({
946
- queryKey: ["wallet-labels-batch", params],
947
- queryFn: ({ pageParam = 0 }) => proxyGet("wallet/labels/batch", { ...params, offset: String(pageParam) }),
948
- initialPageParam: 0,
949
- getNextPageParam: (last) => {
950
- const m = last?.meta;
951
- if (!m?.total || !m?.limit) return void 0;
952
- const next = (m.offset ?? 0) + m.limit;
953
- return next < m.total ? next : void 0;
954
- }
955
- });
956
- }
957
- function useInfiniteWalletNetWorth(params) {
958
- return useInfiniteQuery13({
959
- queryKey: ["wallet-net-worth", params],
960
- queryFn: ({ pageParam = 0 }) => proxyGet("wallet/net-worth", { ...params, offset: String(pageParam) }),
961
- initialPageParam: 0,
962
- getNextPageParam: (last) => {
963
- const m = last?.meta;
964
- if (!m?.total || !m?.limit) return void 0;
965
- const next = (m.offset ?? 0) + m.limit;
966
- return next < m.total ? next : void 0;
967
- }
968
- });
969
- }
970
- function useInfiniteWalletProtocols(params) {
971
- return useInfiniteQuery13({
972
- queryKey: ["wallet-protocols", params],
973
- queryFn: ({ pageParam = 0 }) => proxyGet("wallet/protocols", { ...params, offset: String(pageParam) }),
974
- initialPageParam: 0,
975
- getNextPageParam: (last) => {
976
- const m = last?.meta;
977
- if (!m?.total || !m?.limit) return void 0;
978
- const next = (m.offset ?? 0) + m.limit;
979
- return next < m.total ? next : void 0;
980
- }
981
- });
982
- }
983
- function useInfiniteWalletTransfers(params) {
984
- return useInfiniteQuery13({
985
- queryKey: ["wallet-transfers", params],
986
- queryFn: ({ pageParam = 0 }) => proxyGet("wallet/transfers", { ...params, offset: String(pageParam) }),
987
- initialPageParam: 0,
988
- getNextPageParam: (last) => {
989
- const m = last?.meta;
990
- if (!m?.total || !m?.limit) return void 0;
991
- const next = (m.offset ?? 0) + m.limit;
992
- return next < m.total ? next : void 0;
993
- }
994
- });
995
- }
996
-
997
- // src/react/hooks/web.ts
998
- import { useQuery as useQuery14 } from "@tanstack/react-query";
999
- function useWebFetch(params) {
1000
- return useQuery14({
1001
- queryKey: ["web-fetch", params],
1002
- queryFn: () => proxyGet("web/fetch", params)
1003
- });
1004
- }
1005
- export {
1006
- cn,
1007
- toast,
1008
- useExchangeDepth,
1009
- useExchangeFundingHistory,
1010
- useExchangeKlines,
1011
- useExchangeLongShortRatio,
1012
- useExchangeMarkets,
1013
- useExchangePerp,
1014
- useExchangePrice,
1015
- useFundDetail,
1016
- useInfiniteFundPortfolio,
1017
- useInfiniteFundRanking,
1018
- useInfiniteKalshiEvents,
1019
- useInfiniteKalshiMarkets,
1020
- useInfiniteKalshiOpenInterest,
1021
- useInfiniteKalshiPrices,
1022
- useInfiniteKalshiRanking,
1023
- useInfiniteKalshiTrades,
1024
- useInfiniteKalshiVolumes,
1025
- useInfiniteMarketRanking,
1026
- useInfiniteNewsFeed,
1027
- useInfiniteOnchainBridgeRanking,
1028
- useInfiniteOnchainSchema,
1029
- useInfiniteOnchainSql,
1030
- useInfiniteOnchainStructuredQuery,
1031
- useInfiniteOnchainTx,
1032
- useInfiniteOnchainYieldRanking,
1033
- useInfinitePolymarketActivity,
1034
- useInfinitePolymarketEvents,
1035
- useInfinitePolymarketMarkets,
1036
- useInfinitePolymarketOpenInterest,
1037
- useInfinitePolymarketPositions,
1038
- useInfinitePolymarketPrices,
1039
- useInfinitePolymarketRanking,
1040
- useInfinitePolymarketTrades,
1041
- useInfinitePolymarketVolumes,
1042
- useInfinitePredictionMarketCategoryMetrics,
1043
- useInfiniteProjectDefiMetrics,
1044
- useInfiniteProjectDefiRanking,
1045
- useInfiniteSearchAirdrop,
1046
- useInfiniteSearchEvents,
1047
- useInfiniteSearchFund,
1048
- useInfiniteSearchKalshi,
1049
- useInfiniteSearchNews,
1050
- useInfiniteSearchPolymarket,
1051
- useInfiniteSearchProject,
1052
- useInfiniteSearchSocialPeople,
1053
- useInfiniteSearchSocialPosts,
1054
- useInfiniteSearchWallet,
1055
- useInfiniteSearchWeb,
1056
- useInfiniteSocialMindshare,
1057
- useInfiniteSocialRanking,
1058
- useInfiniteSocialSmartFollowersHistory,
1059
- useInfiniteSocialTweetReplies,
1060
- useInfiniteSocialTweets,
1061
- useInfiniteSocialUserFollowers,
1062
- useInfiniteSocialUserFollowing,
1063
- useInfiniteSocialUserPosts,
1064
- useInfiniteSocialUserReplies,
1065
- useInfiniteTokenDexTrades,
1066
- useInfiniteTokenHolders,
1067
- useInfiniteTokenTokenomics,
1068
- useInfiniteTokenTransfers,
1069
- useInfiniteWalletHistory,
1070
- useInfiniteWalletLabelsBatch,
1071
- useInfiniteWalletNetWorth,
1072
- useInfiniteWalletProtocols,
1073
- useInfiniteWalletTransfers,
1074
- useMarketEtf,
1075
- useMarketFearGreed,
1076
- useMarketFutures,
1077
- useMarketLiquidationChart,
1078
- useMarketLiquidationExchangeList,
1079
- useMarketLiquidationOrder,
1080
- useMarketOnchainIndicator,
1081
- useMarketOptions,
1082
- useMarketPrice,
1083
- useMarketPriceIndicator,
1084
- useNewsDetail,
1085
- useOnchainGasPrice,
1086
- useProjectDetail,
1087
- useSocialDetail,
1088
- useSocialUser,
1089
- useToast,
1090
- useWalletDetail,
1091
- useWebFetch
1092
- };