@silentswap/react 0.0.65 → 0.0.67

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.
@@ -7,6 +7,10 @@ export type PlatformHealthContextType = {
7
7
  outputLimit: number | undefined;
8
8
  serviceFeeRate: number | undefined;
9
9
  overheadUsd: number | undefined;
10
+ identity: string | undefined;
11
+ volume: number | undefined;
12
+ liquidity: number | undefined;
13
+ storage: Record<string, string> | undefined;
10
14
  formDisabled: boolean;
11
15
  trackingDisabled: boolean;
12
16
  validateDepositAmount: (usdAmount: string | number) => {
@@ -23,6 +27,11 @@ export type PlatformHealthContextType = {
23
27
  };
24
28
  export type PlatformHealthProviderProps = {
25
29
  children: React.ReactNode;
30
+ /**
31
+ * Pro user ID for volume tracking (from ?pro= URL or localStorage silentswap:pro).
32
+ * When set, status is fetched with ?pro= and identity/volume/liquidity are returned.
33
+ */
34
+ proId?: string;
26
35
  /**
27
36
  * Optional callback to update form disabled state in app state
28
37
  * If not provided, formDisabled will always be false in the context
@@ -38,7 +47,7 @@ export type PlatformHealthProviderProps = {
38
47
  * Provider that monitors platform health from status API and provides validation functions
39
48
  * for deposit amounts, output limits, and service fee rates
40
49
  */
41
- export declare function PlatformHealthProvider({ children, onFormDisabledChange, onTrackingDisabledChange, }: PlatformHealthProviderProps): import("react/jsx-runtime").JSX.Element;
50
+ export declare function PlatformHealthProvider({ children, proId, onFormDisabledChange, onTrackingDisabledChange, }: PlatformHealthProviderProps): import("react/jsx-runtime").JSX.Element;
42
51
  /**
43
52
  * Hook to access platform health context
44
53
  */
@@ -8,8 +8,8 @@ const PlatformHealthContext = createContext(undefined);
8
8
  * Provider that monitors platform health from status API and provides validation functions
9
9
  * for deposit amounts, output limits, and service fee rates
10
10
  */
11
- export function PlatformHealthProvider({ children, onFormDisabledChange, onTrackingDisabledChange, }) {
12
- const { platformHealth: statusPlatformHealth, maximumDepositUusdc, minimumDepositUusdc, outputLimit, serviceFeeRate, overheadUsd, } = useStatus();
11
+ export function PlatformHealthProvider({ children, proId, onFormDisabledChange, onTrackingDisabledChange, }) {
12
+ const { platformHealth: statusPlatformHealth, maximumDepositUusdc, minimumDepositUusdc, outputLimit, serviceFeeRate, overheadUsd, identity, volume, liquidity, storage, } = useStatus(proId != null ? { proId } : undefined);
13
13
  // Normalize platform health status
14
14
  const platformHealth = useMemo(() => {
15
15
  if (!statusPlatformHealth)
@@ -136,6 +136,10 @@ export function PlatformHealthProvider({ children, onFormDisabledChange, onTrack
136
136
  outputLimit: outputLimit ?? undefined,
137
137
  serviceFeeRate: serviceFeeRate ?? undefined,
138
138
  overheadUsd: overheadUsd ?? undefined,
139
+ identity,
140
+ volume,
141
+ liquidity,
142
+ storage,
139
143
  formDisabled,
140
144
  trackingDisabled,
141
145
  validateDepositAmount,
@@ -150,6 +154,10 @@ export function PlatformHealthProvider({ children, onFormDisabledChange, onTrack
150
154
  outputLimit,
151
155
  serviceFeeRate,
152
156
  overheadUsd,
157
+ identity,
158
+ volume,
159
+ liquidity,
160
+ storage,
153
161
  formDisabled,
154
162
  trackingDisabled,
155
163
  validateDepositAmount,
@@ -8,11 +8,18 @@ export interface StatusResponse {
8
8
  volume?: number;
9
9
  liquidity?: number;
10
10
  identity?: string;
11
+ /** Pro user: key-value storage to apply to localStorage when authenticated */
12
+ storage?: Record<string, string>;
13
+ }
14
+ export interface UseStatusOptions {
15
+ /** Pro user ID for volume tracking (from ?pro= URL or localStorage) */
16
+ proId?: string;
11
17
  }
12
18
  /**
13
19
  * Hook to fetch the current platform status, fee rates, and limits
20
+ * When proId is provided, fetches with ?pro= for pro user volume tracking and returns identity/volume/liquidity.
14
21
  */
15
- export declare function useStatus(): {
22
+ export declare function useStatus(options?: UseStatusOptions): {
16
23
  status: StatusResponse;
17
24
  isLoading: boolean;
18
25
  error: Error | null;
@@ -22,4 +29,8 @@ export declare function useStatus(): {
22
29
  maximumDepositUusdc: string | undefined;
23
30
  platformHealth: "UNKNOWN" | "ON" | "OFF" | "PAUSED" | "ONLINE" | "DEPOSITS_PAUSED" | "MAINTENANCE" | undefined;
24
31
  outputLimit: number | undefined;
32
+ identity: string | undefined;
33
+ volume: number | undefined;
34
+ liquidity: number | undefined;
35
+ storage: Record<string, string> | undefined;
25
36
  };
@@ -2,10 +2,12 @@ import { useState, useEffect } from 'react';
2
2
  import { useSilentSwap } from '../contexts/SilentSwapContext.js';
3
3
  /**
4
4
  * Hook to fetch the current platform status, fee rates, and limits
5
+ * When proId is provided, fetches with ?pro= for pro user volume tracking and returns identity/volume/liquidity.
5
6
  */
6
- export function useStatus() {
7
+ export function useStatus(options) {
7
8
  const { config, client } = useSilentSwap();
8
9
  const baseUrl = config.baseUrl;
10
+ const proId = options?.proId;
9
11
  const [status, setStatus] = useState({});
10
12
  const [isLoading, setIsLoading] = useState(true);
11
13
  const [error, setError] = useState(null);
@@ -32,7 +34,8 @@ export function useStatus() {
32
34
  const fetchStatus = async () => {
33
35
  try {
34
36
  setIsLoading(true);
35
- const statusUrl = `${baseUrl}/status`;
37
+ const search = proId ? `?${new URLSearchParams({ pro: proId }).toString()}` : '';
38
+ const statusUrl = `${baseUrl}/status${search}`;
36
39
  console.log('[useStatus] Fetching status from:', statusUrl, 'environment:', config.environment);
37
40
  const response = await fetch(statusUrl);
38
41
  if (!response.ok) {
@@ -63,7 +66,7 @@ export function useStatus() {
63
66
  return () => {
64
67
  isMounted = false;
65
68
  };
66
- }, [baseUrl, config.environment]);
69
+ }, [baseUrl, config.environment, proId]);
67
70
  // Convert overheadUsd from string to number
68
71
  const overheadUsd = status.overheadUsd ? parseFloat(status.overheadUsd) : 0;
69
72
  // serviceFeeRate is a Decimal (0.01 = 1%), convert to number
@@ -78,5 +81,9 @@ export function useStatus() {
78
81
  maximumDepositUusdc: status.maximumDepositUusdc,
79
82
  platformHealth: status.platformHealth,
80
83
  outputLimit: status.outputLimit,
84
+ identity: status.identity,
85
+ volume: status.volume,
86
+ liquidity: status.liquidity,
87
+ storage: status.storage,
81
88
  };
82
89
  }
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ export type { Destination, SwapState } from './hooks/useSwap.js';
24
24
  export { useEgressEstimates } from './hooks/useEgressEstimates.js';
25
25
  export type { UseEgressEstimatesOptions } from './hooks/useEgressEstimates.js';
26
26
  export { useStatus } from './hooks/useStatus.js';
27
- export type { StatusResponse } from './hooks/useStatus.js';
27
+ export type { StatusResponse, UseStatusOptions } from './hooks/useStatus.js';
28
28
  export { PlatformHealthProvider, usePlatformHealthContext } from './hooks/usePlatformHealth.js';
29
29
  export type { PlatformHealthStatus, PlatformHealthContextType, PlatformHealthProviderProps, } from './hooks/usePlatformHealth.js';
30
30
  export { PlatformHealthMonitor, usePlatformHealthMonitor, } from './hooks/usePlatformHealthMonitor.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@silentswap/react",
3
3
  "type": "module",
4
- "version": "0.0.65",
4
+ "version": "0.0.67",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -24,8 +24,8 @@
24
24
  "dependencies": {
25
25
  "@bigmi/core": "^0.6.5",
26
26
  "@ensdomains/ensjs": "^4.2.0",
27
- "@silentswap/sdk": "0.0.65",
28
- "@silentswap/ui-kit": "0.0.65",
27
+ "@silentswap/sdk": "0.0.67",
28
+ "@silentswap/ui-kit": "0.0.67",
29
29
  "@solana/codecs-strings": "^5.1.0",
30
30
  "@solana/kit": "^5.1.0",
31
31
  "@solana/rpc": "^5.1.0",