@turtleclub/hooks 0.5.0-beta.76 → 0.5.0-beta.78

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.js CHANGED
@@ -996,6 +996,8 @@ var opportunitySchema = z8.object({
996
996
  turtleTvl: z8.number(),
997
997
  turtleUsers: z8.number(),
998
998
  earnEnabled: z8.boolean(),
999
+ swapDirectEnabled: z8.boolean().optional().default(true),
1000
+ swapRouteEnabled: z8.boolean().optional().default(false),
999
1001
  createdAt: z8.string().datetime().optional(),
1000
1002
  updatedAt: z8.string().datetime().optional(),
1001
1003
  mainStreamId: z8.string().optional(),
@@ -1949,6 +1951,15 @@ var checkCoverRequestResponseSchema = z16.object({
1949
1951
  canSubmit: z16.boolean(),
1950
1952
  existingRequest: coverRequestDataSchema.nullable()
1951
1953
  });
1954
+ var submitCoverPurchaseDataSchema = z16.object({
1955
+ walletAddress: z16.string().regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address"),
1956
+ txHash: z16.string().regex(/^0x[a-fA-F0-9]{64}$/, "Invalid transaction hash")
1957
+ });
1958
+ var submitCoverPurchaseResponseSchema = z16.object({
1959
+ success: z16.boolean(),
1960
+ message: z16.string(),
1961
+ id: z16.string()
1962
+ });
1952
1963
 
1953
1964
  // src/v2/covers/api.ts
1954
1965
  async function submitCoverRequest(data) {
@@ -1958,11 +1969,23 @@ async function submitCoverRequest(data) {
1958
1969
  });
1959
1970
  const result = submitCoverRequestResponseSchema.safeParse(response);
1960
1971
  if (!result.success) {
1961
- console.log("[ZOD ERROR]", result.error);
1972
+ console.error("[ZOD ERROR]", result.error);
1962
1973
  throw new Error(`Failed to submit cover request due to an invalid server response.`);
1963
1974
  }
1964
1975
  return result.data;
1965
1976
  }
1977
+ async function submitCoverPurchase(data) {
1978
+ const response = await apiClient.fetch("/turtle/nexus-cover-purchases", {
1979
+ method: "POST",
1980
+ body: data
1981
+ });
1982
+ const result = submitCoverPurchaseResponseSchema.safeParse(response);
1983
+ if (!result.success) {
1984
+ console.error("[ZOD ERROR]", result.error);
1985
+ throw new Error("Failed to submit cover purchase tracking due to an invalid server response.");
1986
+ }
1987
+ return result.data;
1988
+ }
1966
1989
  async function checkCoverRequest({
1967
1990
  protocolName
1968
1991
  }) {
@@ -2418,6 +2441,22 @@ import { useQuery as useQuery9 } from "@tanstack/react-query";
2418
2441
  // src/v2/earn-deposits/hooks/useDepositValidation.ts
2419
2442
  import { useMemo as useMemo2 } from "react";
2420
2443
  import { formatUnits } from "viem";
2444
+
2445
+ // src/v2/earn-deposits/hooks/utils.ts
2446
+ function getDepositModeFlags(opportunity) {
2447
+ const isSecondaryOnly = opportunity?.vaultConfig?.secondaryOnly === true;
2448
+ const routeModeEnabled = opportunity?.swapRouteEnabled ?? false;
2449
+ const directModeEnabled = opportunity?.swapDirectEnabled ?? true;
2450
+ const noModesEnabled = !routeModeEnabled && !directModeEnabled;
2451
+ return { isSecondaryOnly, routeModeEnabled, directModeEnabled, noModesEnabled };
2452
+ }
2453
+ function resolveEffectiveDepositMode(depositMode, flags) {
2454
+ if (flags.isSecondaryOnly) return "route";
2455
+ if (!flags.directModeEnabled && flags.routeModeEnabled) return "route";
2456
+ return depositMode;
2457
+ }
2458
+
2459
+ // src/v2/earn-deposits/hooks/useDepositValidation.ts
2421
2460
  function calculateUsdValue(amount, token) {
2422
2461
  if (!token.priceUsd) return null;
2423
2462
  const formatted = parseFloat(formatUnits(amount, token.decimals));
@@ -2463,7 +2502,8 @@ function useDepositValidation({
2463
2502
  };
2464
2503
  }
2465
2504
  const vaultConfig = opportunity.vaultConfig;
2466
- const depositDisabled = opportunity.depositDisabled ?? false;
2505
+ const { noModesEnabled } = getDepositModeFlags(opportunity);
2506
+ const depositDisabled = (opportunity.depositDisabled ?? false) || noModesEnabled;
2467
2507
  const depositDisabledReason = opportunity.depositDisabledReason || null;
2468
2508
  const depositFee = vaultConfig?.depositFee ?? null;
2469
2509
  const performanceFee = vaultConfig?.performanceFee ?? null;
@@ -3357,8 +3397,8 @@ function useActionsDefaultParams({
3357
3397
  depositMode
3358
3398
  }) {
3359
3399
  const opportunityChainId = opportunity ? Number(opportunity.receiptToken.chain.chainId) : void 0;
3360
- const isSecondaryOnly = opportunity?.vaultConfig?.secondaryOnly === true;
3361
- const effectiveDepositMode = isSecondaryOnly ? "route" : depositMode;
3400
+ const flags = getDepositModeFlags(opportunity);
3401
+ const effectiveDepositMode = resolveEffectiveDepositMode(depositMode, flags);
3362
3402
  const useOnChainBalances = effectiveDepositMode === "native";
3363
3403
  const {
3364
3404
  balances: depositTokenBalances,
@@ -4383,6 +4423,7 @@ export {
4383
4423
  filterTagSchema,
4384
4424
  geoCheckResponseSchema,
4385
4425
  geocheckQueries,
4426
+ getDepositModeFlags,
4386
4427
  getDeposits,
4387
4428
  getEarnOpportunities,
4388
4429
  getEarnRoute,
@@ -4459,6 +4500,7 @@ export {
4459
4500
  productsResponseSchema,
4460
4501
  queries,
4461
4502
  requestStreamSignature,
4503
+ resolveEffectiveDepositMode,
4462
4504
  routeMetadataSchema,
4463
4505
  routeStepSchema,
4464
4506
  routeToken,
@@ -4475,6 +4517,9 @@ export {
4475
4517
  streamWalletSchema,
4476
4518
  streamWalletSnapshotSchema,
4477
4519
  streamsQueries,
4520
+ submitCoverPurchase,
4521
+ submitCoverPurchaseDataSchema,
4522
+ submitCoverPurchaseResponseSchema,
4478
4523
  submitCoverRequest,
4479
4524
  submitCoverRequestResponseSchema,
4480
4525
  supportedChainEcosystemSchema,