@turtleclub/hooks 0.5.0-beta.25 → 0.5.0-beta.26
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 +197 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +186 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/v2/opportunities/api.ts +64 -2
- package/src/v2/opportunities/hooks.ts +37 -1
- package/src/v2/opportunities/index.ts +36 -3
- package/src/v2/opportunities/queries.ts +19 -2
- package/src/v2/opportunities/schema.ts +121 -0
package/dist/index.cjs
CHANGED
|
@@ -71,11 +71,18 @@ __export(index_exports, {
|
|
|
71
71
|
filterBalancesByChains: () => filterBalancesByChains,
|
|
72
72
|
filterExcludedTokens: () => filterExcludedTokens,
|
|
73
73
|
filterNonZeroBalances: () => filterNonZeroBalances,
|
|
74
|
+
filterOrganizationSchema: () => filterOrganizationSchema,
|
|
75
|
+
filterTagSchema: () => filterTagSchema,
|
|
74
76
|
geocheckQueryOptions: () => geocheckQueryOptions,
|
|
75
77
|
getDeposits: () => getDeposits,
|
|
76
78
|
getEarnOpportunities: () => getEarnOpportunities,
|
|
77
79
|
getEarnRoute: () => getEarnRoute,
|
|
78
80
|
getOpportunities: () => getOpportunities,
|
|
81
|
+
getOpportunitiesFilterOptions: () => getOpportunitiesFilterOptions,
|
|
82
|
+
getOpportunitiesFilterOptionsSchema: () => getOpportunitiesFilterOptionsSchema,
|
|
83
|
+
getOpportunitiesPaginated: () => getOpportunitiesPaginated,
|
|
84
|
+
getOpportunitiesPaginatedInputSchema: () => getOpportunitiesPaginatedInputSchema,
|
|
85
|
+
getOpportunitiesPaginatedSchema: () => getOpportunitiesPaginatedSchema,
|
|
79
86
|
getOpportunityById: () => getOpportunityById,
|
|
80
87
|
getPortfolioBalance: () => getPortfolioBalance,
|
|
81
88
|
getProducts: () => getProducts,
|
|
@@ -106,6 +113,8 @@ __export(index_exports, {
|
|
|
106
113
|
mergeBalancesByPriority: () => mergeBalancesByPriority,
|
|
107
114
|
nftsQueries: () => nftsQueries,
|
|
108
115
|
opportunitiesQueries: () => opportunitiesQueries,
|
|
116
|
+
opportunitiesResponseSchema: () => opportunitiesResponseSchema,
|
|
117
|
+
opportunityFiltersSchema: () => opportunityFiltersSchema,
|
|
109
118
|
opportunitySchema: () => opportunitySchema,
|
|
110
119
|
organizationSchema: () => organizationSchema,
|
|
111
120
|
paginationMetadataSchema: () => paginationMetadataSchema,
|
|
@@ -165,6 +174,8 @@ __export(index_exports, {
|
|
|
165
174
|
useGetOnChainBalance: () => useGetOnChainBalance,
|
|
166
175
|
useMultiChainBalances: () => useMultiChainBalances,
|
|
167
176
|
useOpportunities: () => useOpportunities,
|
|
177
|
+
useOpportunitiesFilterOptions: () => useOpportunitiesFilterOptions,
|
|
178
|
+
useOpportunitiesPaginated: () => useOpportunitiesPaginated,
|
|
168
179
|
useOpportunity: () => useOpportunity,
|
|
169
180
|
usePortfolioBalance: () => usePortfolioBalance,
|
|
170
181
|
useProduct: () => useProduct,
|
|
@@ -450,6 +461,117 @@ var opportunitiesResponseSchema = import_zod2.z.object({
|
|
|
450
461
|
opportunities: import_zod2.z.array(opportunitySchema),
|
|
451
462
|
total: import_zod2.z.number().optional()
|
|
452
463
|
});
|
|
464
|
+
var getOpportunitiesPaginatedInputSchema = import_zod2.z.object({
|
|
465
|
+
page: import_zod2.z.number().min(1).default(1),
|
|
466
|
+
limit: import_zod2.z.number().min(1).max(100).default(10),
|
|
467
|
+
// Sorting
|
|
468
|
+
sortBy: import_zod2.z.enum([
|
|
469
|
+
"turtleTvl",
|
|
470
|
+
"tvl",
|
|
471
|
+
"name",
|
|
472
|
+
"turtleUsers",
|
|
473
|
+
"type",
|
|
474
|
+
"organization",
|
|
475
|
+
"curator",
|
|
476
|
+
"provider",
|
|
477
|
+
"apr"
|
|
478
|
+
]).optional(),
|
|
479
|
+
sortOrder: import_zod2.z.enum(["asc", "desc"]).optional(),
|
|
480
|
+
// Filter by receipt token chain (comma-separated)
|
|
481
|
+
receiptTokenChainId: import_zod2.z.string().optional(),
|
|
482
|
+
// Comma-separated UUIDs
|
|
483
|
+
receiptTokenChainSlug: import_zod2.z.string().optional(),
|
|
484
|
+
// Comma-separated slugs
|
|
485
|
+
// Filter by deposit token
|
|
486
|
+
depositTokenGroup: import_zod2.z.string().optional(),
|
|
487
|
+
depositTokenSymbols: import_zod2.z.string().optional(),
|
|
488
|
+
// Comma-separated symbols
|
|
489
|
+
depositTokenChainId: import_zod2.z.string().optional(),
|
|
490
|
+
// Filter by tags (comma-separated)
|
|
491
|
+
tags: import_zod2.z.string().optional(),
|
|
492
|
+
// Filter by IDs (comma-separated UUIDs)
|
|
493
|
+
productId: import_zod2.z.string().optional(),
|
|
494
|
+
// Comma-separated UUIDs
|
|
495
|
+
curatorId: import_zod2.z.string().optional(),
|
|
496
|
+
// Comma-separated UUIDs
|
|
497
|
+
providerId: import_zod2.z.string().optional(),
|
|
498
|
+
// Comma-separated UUIDs
|
|
499
|
+
partnerId: import_zod2.z.string().optional(),
|
|
500
|
+
// Comma-separated UUIDs
|
|
501
|
+
lendingProtocolId: import_zod2.z.string().optional(),
|
|
502
|
+
// Comma-separated UUIDs
|
|
503
|
+
// Status filters
|
|
504
|
+
withdrawalDisabled: import_zod2.z.boolean().optional(),
|
|
505
|
+
depositDisabled: import_zod2.z.boolean().optional(),
|
|
506
|
+
status: import_zod2.z.string().optional(),
|
|
507
|
+
earnEnabled: import_zod2.z.boolean().optional(),
|
|
508
|
+
featured: import_zod2.z.boolean().optional(),
|
|
509
|
+
// TVL filters
|
|
510
|
+
tvlGreaterThan: import_zod2.z.number().optional(),
|
|
511
|
+
turtleTvlGreaterThan: import_zod2.z.number().optional(),
|
|
512
|
+
tvlMin: import_zod2.z.number().optional(),
|
|
513
|
+
tvlMax: import_zod2.z.number().optional(),
|
|
514
|
+
// APR filters
|
|
515
|
+
minApr: import_zod2.z.number().optional(),
|
|
516
|
+
maxApr: import_zod2.z.number().optional(),
|
|
517
|
+
// Chain IDs (comma-separated)
|
|
518
|
+
chainIds: import_zod2.z.string().optional(),
|
|
519
|
+
// Search
|
|
520
|
+
search: import_zod2.z.string().optional()
|
|
521
|
+
});
|
|
522
|
+
var paginationMetadataSchema2 = import_zod2.z.object({
|
|
523
|
+
page: import_zod2.z.number(),
|
|
524
|
+
limit: import_zod2.z.number(),
|
|
525
|
+
total: import_zod2.z.number(),
|
|
526
|
+
totalPages: import_zod2.z.number()
|
|
527
|
+
});
|
|
528
|
+
var getOpportunitiesPaginatedSchema = import_zod2.z.object({
|
|
529
|
+
opportunities: import_zod2.z.array(opportunitySchema),
|
|
530
|
+
pagination: paginationMetadataSchema2
|
|
531
|
+
});
|
|
532
|
+
var filterChainSchema = import_zod2.z.object({
|
|
533
|
+
id: import_zod2.z.string().uuid(),
|
|
534
|
+
name: import_zod2.z.string(),
|
|
535
|
+
slug: import_zod2.z.string(),
|
|
536
|
+
chainId: import_zod2.z.string(),
|
|
537
|
+
logoUrl: import_zod2.z.string(),
|
|
538
|
+
ecosystem: import_zod2.z.string(),
|
|
539
|
+
status: import_zod2.z.string(),
|
|
540
|
+
explorerUrl: import_zod2.z.string()
|
|
541
|
+
});
|
|
542
|
+
var filterOrganizationSchema = import_zod2.z.object({
|
|
543
|
+
id: import_zod2.z.string().uuid(),
|
|
544
|
+
name: import_zod2.z.string(),
|
|
545
|
+
description: import_zod2.z.string(),
|
|
546
|
+
landingUrl: import_zod2.z.string(),
|
|
547
|
+
iconUrl: import_zod2.z.string(),
|
|
548
|
+
organizationType: import_zod2.z.string(),
|
|
549
|
+
turtleRefCode: import_zod2.z.string(),
|
|
550
|
+
twitterHandle: import_zod2.z.string(),
|
|
551
|
+
status: import_zod2.z.string(),
|
|
552
|
+
featured: import_zod2.z.boolean()
|
|
553
|
+
});
|
|
554
|
+
var filterTagSchema = import_zod2.z.object({
|
|
555
|
+
id: import_zod2.z.string().uuid(),
|
|
556
|
+
code: import_zod2.z.string(),
|
|
557
|
+
name: import_zod2.z.string(),
|
|
558
|
+
description: import_zod2.z.string().optional().nullable(),
|
|
559
|
+
color: import_zod2.z.string().optional().nullable(),
|
|
560
|
+
type: import_zod2.z.string().optional().nullable()
|
|
561
|
+
});
|
|
562
|
+
var depositTokenSymbolSchema = import_zod2.z.object({
|
|
563
|
+
symbol: import_zod2.z.string(),
|
|
564
|
+
logoUrl: import_zod2.z.string()
|
|
565
|
+
});
|
|
566
|
+
var getOpportunitiesFilterOptionsSchema = import_zod2.z.object({
|
|
567
|
+
chains: import_zod2.z.array(filterChainSchema),
|
|
568
|
+
providers: import_zod2.z.array(filterOrganizationSchema),
|
|
569
|
+
curators: import_zod2.z.array(filterOrganizationSchema).optional().nullable(),
|
|
570
|
+
partners: import_zod2.z.array(filterOrganizationSchema).optional().nullable(),
|
|
571
|
+
tags: import_zod2.z.array(filterTagSchema).optional().nullable(),
|
|
572
|
+
lendingProtocols: import_zod2.z.array(filterOrganizationSchema),
|
|
573
|
+
depositTokenSymbols: import_zod2.z.array(depositTokenSymbolSchema).optional().nullable()
|
|
574
|
+
});
|
|
453
575
|
|
|
454
576
|
// src/v2/opportunities/api.ts
|
|
455
577
|
async function getOpportunities(filters, options) {
|
|
@@ -482,6 +604,40 @@ async function getOpportunityById(id, options) {
|
|
|
482
604
|
}
|
|
483
605
|
return result.data;
|
|
484
606
|
}
|
|
607
|
+
async function getOpportunitiesPaginated(params, options) {
|
|
608
|
+
const queryParams = new URLSearchParams();
|
|
609
|
+
if (params) {
|
|
610
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
611
|
+
if (value !== void 0 && value !== null) {
|
|
612
|
+
queryParams.append(key, String(value));
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
const queryString = queryParams.toString();
|
|
617
|
+
const endpoint = `/turtle/opportunities-paginated${queryString ? `?${queryString}` : ""}`;
|
|
618
|
+
const data = await apiClient.fetch(endpoint, {
|
|
619
|
+
method: "GET",
|
|
620
|
+
debug: options?.debug
|
|
621
|
+
});
|
|
622
|
+
const result = getOpportunitiesPaginatedSchema.safeParse(data);
|
|
623
|
+
if (result.success === false) {
|
|
624
|
+
console.log("[ZOD ERROR]", result.error);
|
|
625
|
+
throw new Error(`Failed to parse paginated opportunities: ${result.error.message}`);
|
|
626
|
+
}
|
|
627
|
+
return result.data;
|
|
628
|
+
}
|
|
629
|
+
async function getOpportunitiesFilterOptions(options) {
|
|
630
|
+
const data = await apiClient.fetch("/turtle/opportunities-filter-options", {
|
|
631
|
+
method: "GET",
|
|
632
|
+
debug: options?.debug
|
|
633
|
+
});
|
|
634
|
+
const result = getOpportunitiesFilterOptionsSchema.safeParse(data);
|
|
635
|
+
if (result.success === false) {
|
|
636
|
+
console.log("[ZOD ERROR]", result.error);
|
|
637
|
+
throw new Error(`Failed to parse opportunities filter options: ${result.error.message}`);
|
|
638
|
+
}
|
|
639
|
+
return result.data;
|
|
640
|
+
}
|
|
485
641
|
|
|
486
642
|
// src/v2/opportunities/queries.ts
|
|
487
643
|
var opportunitiesQueries = (0, import_query_key_factory.createQueryKeys)("opportunities", {
|
|
@@ -499,7 +655,17 @@ var opportunitiesQueries = (0, import_query_key_factory.createQueryKeys)("opport
|
|
|
499
655
|
byId: (id) => ({
|
|
500
656
|
queryKey: [id],
|
|
501
657
|
queryFn: () => getOpportunityById(id)
|
|
502
|
-
})
|
|
658
|
+
}),
|
|
659
|
+
// Get paginated opportunities
|
|
660
|
+
paginated: (params) => ({
|
|
661
|
+
queryKey: [{ params }],
|
|
662
|
+
queryFn: () => getOpportunitiesPaginated(params)
|
|
663
|
+
}),
|
|
664
|
+
// Get filter options for opportunities
|
|
665
|
+
filterOptions: {
|
|
666
|
+
queryKey: null,
|
|
667
|
+
queryFn: () => getOpportunitiesFilterOptions()
|
|
668
|
+
}
|
|
503
669
|
});
|
|
504
670
|
|
|
505
671
|
// src/v2/earn-opportunities/queries.ts
|
|
@@ -1800,6 +1966,25 @@ function useOpportunity({ id, ...options }) {
|
|
|
1800
1966
|
}
|
|
1801
1967
|
});
|
|
1802
1968
|
}
|
|
1969
|
+
function useOpportunitiesPaginated({
|
|
1970
|
+
params,
|
|
1971
|
+
enabled = true
|
|
1972
|
+
} = {}) {
|
|
1973
|
+
return (0, import_react_query7.useQuery)({
|
|
1974
|
+
...opportunitiesQueries.paginated(params),
|
|
1975
|
+
...queryDefaults,
|
|
1976
|
+
enabled
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
function useOpportunitiesFilterOptions({
|
|
1980
|
+
enabled = true
|
|
1981
|
+
} = {}) {
|
|
1982
|
+
return (0, import_react_query7.useQuery)({
|
|
1983
|
+
...opportunitiesQueries.filterOptions,
|
|
1984
|
+
...queryDefaults,
|
|
1985
|
+
enabled
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1803
1988
|
|
|
1804
1989
|
// src/v2/products/hooks.ts
|
|
1805
1990
|
var import_react_query8 = require("@tanstack/react-query");
|
|
@@ -2677,11 +2862,18 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
|
|
|
2677
2862
|
filterBalancesByChains,
|
|
2678
2863
|
filterExcludedTokens,
|
|
2679
2864
|
filterNonZeroBalances,
|
|
2865
|
+
filterOrganizationSchema,
|
|
2866
|
+
filterTagSchema,
|
|
2680
2867
|
geocheckQueryOptions,
|
|
2681
2868
|
getDeposits,
|
|
2682
2869
|
getEarnOpportunities,
|
|
2683
2870
|
getEarnRoute,
|
|
2684
2871
|
getOpportunities,
|
|
2872
|
+
getOpportunitiesFilterOptions,
|
|
2873
|
+
getOpportunitiesFilterOptionsSchema,
|
|
2874
|
+
getOpportunitiesPaginated,
|
|
2875
|
+
getOpportunitiesPaginatedInputSchema,
|
|
2876
|
+
getOpportunitiesPaginatedSchema,
|
|
2685
2877
|
getOpportunityById,
|
|
2686
2878
|
getPortfolioBalance,
|
|
2687
2879
|
getProducts,
|
|
@@ -2712,6 +2904,8 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
|
|
|
2712
2904
|
mergeBalancesByPriority,
|
|
2713
2905
|
nftsQueries,
|
|
2714
2906
|
opportunitiesQueries,
|
|
2907
|
+
opportunitiesResponseSchema,
|
|
2908
|
+
opportunityFiltersSchema,
|
|
2715
2909
|
opportunitySchema,
|
|
2716
2910
|
organizationSchema,
|
|
2717
2911
|
paginationMetadataSchema,
|
|
@@ -2771,6 +2965,8 @@ var queries = (0, import_query_key_factory16.mergeQueryKeys)(
|
|
|
2771
2965
|
useGetOnChainBalance,
|
|
2772
2966
|
useMultiChainBalances,
|
|
2773
2967
|
useOpportunities,
|
|
2968
|
+
useOpportunitiesFilterOptions,
|
|
2969
|
+
useOpportunitiesPaginated,
|
|
2774
2970
|
useOpportunity,
|
|
2775
2971
|
usePortfolioBalance,
|
|
2776
2972
|
useProduct,
|