@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turtleclub/hooks",
3
3
  "type": "module",
4
- "version": "0.5.0-beta.77",
4
+ "version": "0.5.0-beta.78",
5
5
  "license": "MIT",
6
6
  "exports": {
7
7
  ".": {
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "117f7b3cc5ea1bcf5c2096ede86145890e8f75ab"
57
+ "gitHead": "779a08749b5462c7c3e32f110a867db992416687"
58
58
  }
@@ -5,6 +5,7 @@ import { filterExcludedTokens } from "../../balance/utils";
5
5
 
6
6
  import type { TokenBalance } from "../../balance/types";
7
7
  import { Opportunity } from "../../opportunities";
8
+ import { getDepositModeFlags, resolveEffectiveDepositMode } from "./utils";
8
9
 
9
10
  export interface UseActionsDefaultParamsOptions {
10
11
  opportunity: Opportunity | null;
@@ -41,9 +42,9 @@ export function useActionsDefaultParams({
41
42
  ? Number(opportunity.receiptToken.chain.chainId)
42
43
  : undefined;
43
44
 
44
- // Secondary market always uses route/swap mode for balance fetching
45
- const isSecondaryOnly = opportunity?.vaultConfig?.secondaryOnly === true;
46
- const effectiveDepositMode = isSecondaryOnly ? "route" : depositMode;
45
+ // Determine effective deposit mode based on swap flags
46
+ const flags = getDepositModeFlags(opportunity);
47
+ const effectiveDepositMode = resolveEffectiveDepositMode(depositMode, flags);
47
48
  const useOnChainBalances = effectiveDepositMode === "native";
48
49
 
49
50
  // Fetch deposit token balances (on-chain)
@@ -3,6 +3,7 @@ import { useMemo } from "react";
3
3
  import type { TokenBalance } from "../../balance/types";
4
4
  import { formatUnits } from "viem";
5
5
  import { Opportunity } from "../../opportunities";
6
+ import { getDepositModeFlags } from "./utils";
6
7
 
7
8
  export interface UseDepositValidationOptions {
8
9
  opportunity: Opportunity | null;
@@ -114,7 +115,8 @@ export function useDepositValidation({
114
115
  }
115
116
 
116
117
  const vaultConfig = opportunity.vaultConfig;
117
- const depositDisabled = opportunity.depositDisabled ?? false;
118
+ const { noModesEnabled } = getDepositModeFlags(opportunity);
119
+ const depositDisabled = (opportunity.depositDisabled ?? false) || noModesEnabled;
118
120
  const depositDisabledReason = opportunity.depositDisabledReason || null;
119
121
 
120
122
  const depositFee = vaultConfig?.depositFee ?? null;
@@ -0,0 +1,27 @@
1
+ import type { Opportunity } from "../../opportunities";
2
+
3
+ export type DepositMode = "native" | "route";
4
+
5
+ export interface DepositModeFlags {
6
+ isSecondaryOnly: boolean;
7
+ routeModeEnabled: boolean;
8
+ directModeEnabled: boolean;
9
+ noModesEnabled: boolean;
10
+ }
11
+
12
+ export function getDepositModeFlags(opportunity: Opportunity | null): DepositModeFlags {
13
+ const isSecondaryOnly = opportunity?.vaultConfig?.secondaryOnly === true;
14
+ const routeModeEnabled = opportunity?.swapRouteEnabled ?? false;
15
+ const directModeEnabled = opportunity?.swapDirectEnabled ?? true;
16
+ const noModesEnabled = !routeModeEnabled && !directModeEnabled;
17
+ return { isSecondaryOnly, routeModeEnabled, directModeEnabled, noModesEnabled };
18
+ }
19
+
20
+ export function resolveEffectiveDepositMode(
21
+ depositMode: DepositMode,
22
+ flags: DepositModeFlags
23
+ ): DepositMode {
24
+ if (flags.isSecondaryOnly) return "route";
25
+ if (!flags.directModeEnabled && flags.routeModeEnabled) return "route";
26
+ return depositMode;
27
+ }
@@ -43,3 +43,11 @@ export {
43
43
  type UseActionsDefaultParamsOptions,
44
44
  type UseActionsDefaultParamsReturn,
45
45
  } from "./hooks/useActionsDefaultParams";
46
+
47
+ // Re-export deposit mode utilities
48
+ export {
49
+ getDepositModeFlags,
50
+ resolveEffectiveDepositMode,
51
+ type DepositMode,
52
+ type DepositModeFlags,
53
+ } from "./hooks/utils";
@@ -35,6 +35,8 @@ export const opportunitySchema = z.object({
35
35
  turtleTvl: z.number(),
36
36
  turtleUsers: z.number(),
37
37
  earnEnabled: z.boolean(),
38
+ swapDirectEnabled: z.boolean().optional().default(true),
39
+ swapRouteEnabled: z.boolean().optional().default(false),
38
40
  createdAt: z.string().datetime().optional(),
39
41
  updatedAt: z.string().datetime().optional(),
40
42
  mainStreamId: z.string().optional(),