@turtleclub/hooks 0.5.0-beta.77 → 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(),
@@ -2439,6 +2441,22 @@ import { useQuery as useQuery9 } from "@tanstack/react-query";
2439
2441
  // src/v2/earn-deposits/hooks/useDepositValidation.ts
2440
2442
  import { useMemo as useMemo2 } from "react";
2441
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
2442
2460
  function calculateUsdValue(amount, token) {
2443
2461
  if (!token.priceUsd) return null;
2444
2462
  const formatted = parseFloat(formatUnits(amount, token.decimals));
@@ -2484,7 +2502,8 @@ function useDepositValidation({
2484
2502
  };
2485
2503
  }
2486
2504
  const vaultConfig = opportunity.vaultConfig;
2487
- const depositDisabled = opportunity.depositDisabled ?? false;
2505
+ const { noModesEnabled } = getDepositModeFlags(opportunity);
2506
+ const depositDisabled = (opportunity.depositDisabled ?? false) || noModesEnabled;
2488
2507
  const depositDisabledReason = opportunity.depositDisabledReason || null;
2489
2508
  const depositFee = vaultConfig?.depositFee ?? null;
2490
2509
  const performanceFee = vaultConfig?.performanceFee ?? null;
@@ -3378,8 +3397,8 @@ function useActionsDefaultParams({
3378
3397
  depositMode
3379
3398
  }) {
3380
3399
  const opportunityChainId = opportunity ? Number(opportunity.receiptToken.chain.chainId) : void 0;
3381
- const isSecondaryOnly = opportunity?.vaultConfig?.secondaryOnly === true;
3382
- const effectiveDepositMode = isSecondaryOnly ? "route" : depositMode;
3400
+ const flags = getDepositModeFlags(opportunity);
3401
+ const effectiveDepositMode = resolveEffectiveDepositMode(depositMode, flags);
3383
3402
  const useOnChainBalances = effectiveDepositMode === "native";
3384
3403
  const {
3385
3404
  balances: depositTokenBalances,
@@ -4404,6 +4423,7 @@ export {
4404
4423
  filterTagSchema,
4405
4424
  geoCheckResponseSchema,
4406
4425
  geocheckQueries,
4426
+ getDepositModeFlags,
4407
4427
  getDeposits,
4408
4428
  getEarnOpportunities,
4409
4429
  getEarnRoute,
@@ -4480,6 +4500,7 @@ export {
4480
4500
  productsResponseSchema,
4481
4501
  queries,
4482
4502
  requestStreamSignature,
4503
+ resolveEffectiveDepositMode,
4483
4504
  routeMetadataSchema,
4484
4505
  routeStepSchema,
4485
4506
  routeToken,