@turtleclub/hooks 0.2.0-beta.3 → 0.2.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.
- package/dist/index.cjs +29 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -21
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/endpoints/useIndexerTvl.ts +46 -23
- package/src/utils/dataMatching.ts +18 -28
package/dist/index.cjs
CHANGED
|
@@ -264,27 +264,35 @@ var import_react_query4 = require("@tanstack/react-query");
|
|
|
264
264
|
var import_api4 = require("@turtleclub/api");
|
|
265
265
|
function useIndexerTvl(options, { config, queryClient } = {}) {
|
|
266
266
|
const defaultConfig2 = useConfig();
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
267
|
+
const queryResult = (0, import_react_query4.useQuery)(
|
|
268
|
+
{
|
|
269
|
+
queryKey: ["indexer-tvl", options?.projects],
|
|
270
|
+
queryFn: async () => {
|
|
271
|
+
return await (0, import_api4.projectTvl)(config ?? defaultConfig2);
|
|
272
|
+
},
|
|
273
|
+
select: (data) => {
|
|
274
|
+
if (!data) return [];
|
|
275
|
+
const result = Object.entries(data.projects).map(([key, value]) => {
|
|
276
|
+
if (!options?.projects.includes(key)) return null;
|
|
277
|
+
return {
|
|
278
|
+
protocol: key,
|
|
279
|
+
tvl: value.tvl_usd,
|
|
280
|
+
assetTvl: value.asset_tvl_usd,
|
|
281
|
+
debtTvl: value.debt_tvl_usd
|
|
282
|
+
};
|
|
283
|
+
}).filter(Boolean);
|
|
284
|
+
return result;
|
|
285
|
+
},
|
|
286
|
+
staleTime: 5 * 60 * 1e3,
|
|
287
|
+
refetchOnWindowFocus: false,
|
|
288
|
+
refetchOnMount: false,
|
|
289
|
+
refetchOnReconnect: false,
|
|
290
|
+
gcTime: 30 * 60 * 1e3
|
|
291
|
+
// 30 minutos de cache
|
|
278
292
|
},
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
refetchOnMount: false,
|
|
283
|
-
refetchOnReconnect: false,
|
|
284
|
-
gcTime: 30 * 60 * 1e3
|
|
285
|
-
// 30 minutos de cache
|
|
286
|
-
}, queryClient ?? defaultQueryClient);
|
|
287
|
-
return query2;
|
|
293
|
+
queryClient ?? defaultQueryClient
|
|
294
|
+
);
|
|
295
|
+
return queryResult;
|
|
288
296
|
}
|
|
289
297
|
|
|
290
298
|
// src/hooks/endpoints/useOrganizationDeals.ts
|
|
@@ -502,7 +510,7 @@ var import_api14 = require("@turtleclub/api");
|
|
|
502
510
|
function deduplicateDeals(deals) {
|
|
503
511
|
const dealsMap = /* @__PURE__ */ new Map();
|
|
504
512
|
deals.forEach((deal) => {
|
|
505
|
-
const key = deal.metadata.id;
|
|
513
|
+
const key = deal.metadata.id + deal.token.address + deal.token.chain;
|
|
506
514
|
const existing = dealsMap.get(key);
|
|
507
515
|
if (!existing || hasMoreCompleteData(deal, existing)) {
|
|
508
516
|
dealsMap.set(key, deal);
|