funhi-chart 1.0.0

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.
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export interface ChartProps {
3
+ mint: string;
4
+ ticker?: string;
5
+ tokenName?: string;
6
+ socket?: any;
7
+ isConnected?: boolean;
8
+ currentMarketCap?: number;
9
+ analyticsConnected?: boolean;
10
+ analyticsLoading?: boolean;
11
+ }
12
+ declare const FunhiChart: React.FC<ChartProps>;
13
+ export default FunhiChart;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export interface ChartProps {
3
+ mint: string;
4
+ ticker?: string;
5
+ tokenName?: string;
6
+ socket?: any;
7
+ isConnected?: boolean;
8
+ currentMarketCap?: number;
9
+ analyticsConnected?: boolean;
10
+ analyticsLoading?: boolean;
11
+ }
12
+ declare const ProfessionalTradingChartRedux: React.FC<ChartProps>;
13
+ export default ProfessionalTradingChartRedux;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Environment Configuration for Funhi Chart
3
+ *
4
+ * This file provides configuration for the chart component
5
+ * Users can override these values by passing them as props
6
+ */
7
+ export declare const API_CONFIG: {
8
+ readonly BASE_URL: any;
9
+ readonly TIMEOUT: 10000;
10
+ readonly MAX_RETRIES: 3;
11
+ readonly RETRY_DELAY: 1000;
12
+ };
@@ -0,0 +1,94 @@
1
+ interface ComprehensiveAnalytics {
2
+ performance: {
3
+ '24H': {
4
+ gain: number;
5
+ percentage: string;
6
+ isPositive: boolean;
7
+ };
8
+ '7D': {
9
+ gain: number;
10
+ percentage: string;
11
+ isPositive: boolean;
12
+ };
13
+ '1M': {
14
+ gain: number;
15
+ percentage: string;
16
+ isPositive: boolean;
17
+ };
18
+ 'All Time': {
19
+ gain: number;
20
+ percentage: string;
21
+ isPositive: boolean;
22
+ };
23
+ };
24
+ market: {
25
+ marketValue: string;
26
+ price: string;
27
+ marketCap: string;
28
+ circulating: string;
29
+ totalSupply: string;
30
+ };
31
+ '24H': {
32
+ high: string;
33
+ low: string;
34
+ volume: string;
35
+ return: string;
36
+ };
37
+ volume: {
38
+ current: string;
39
+ '24h': string;
40
+ unit: string;
41
+ };
42
+ blockchain: {
43
+ currentRealSol: string;
44
+ realSolReserves: number;
45
+ virtualSolReserves: number;
46
+ tokenReserves: number;
47
+ };
48
+ additional: {
49
+ solUsdPrice: string;
50
+ timestamp: number;
51
+ };
52
+ }
53
+ interface EnhancedTokenAnalytics {
54
+ analytics: ComprehensiveAnalytics | null;
55
+ currentPrice: number;
56
+ currentMarketCap: number;
57
+ currentVolume: number;
58
+ performance24h: {
59
+ value: string;
60
+ isPositive: boolean;
61
+ raw: number;
62
+ };
63
+ performance7d: {
64
+ value: string;
65
+ isPositive: boolean;
66
+ raw: number;
67
+ };
68
+ performance1m: {
69
+ value: string;
70
+ isPositive: boolean;
71
+ raw: number;
72
+ };
73
+ performanceAllTime: {
74
+ value: string;
75
+ isPositive: boolean;
76
+ raw: number;
77
+ };
78
+ high24h: number;
79
+ low24h: number;
80
+ volume24h: number;
81
+ return24h: number;
82
+ loading: boolean;
83
+ error: string | null;
84
+ connected: boolean;
85
+ lastUpdate: number | null;
86
+ isRealVolume: (volume: number) => boolean;
87
+ }
88
+ /**
89
+ * Simplified hook for token analytics
90
+ * This is a stub version for the NPM package
91
+ * Users should provide their own analytics data or implement their own hook
92
+ */
93
+ export declare function useOptimizedTokenAnalytics(mint: string | undefined, analyticsData?: any): EnhancedTokenAnalytics;
94
+ export {};
@@ -0,0 +1,46 @@
1
+ import { Socket } from 'socket.io-client';
2
+ interface OHLCVCandle {
3
+ time: number;
4
+ open: number;
5
+ high: number;
6
+ low: number;
7
+ close: number;
8
+ volume: number;
9
+ }
10
+ interface OHLCVInitialData {
11
+ mint: string;
12
+ timeFrame: number;
13
+ data: OHLCVCandle[];
14
+ timestamp: number;
15
+ error?: string;
16
+ }
17
+ interface OHLCVUpdateData {
18
+ mint: string;
19
+ timeFrame: number;
20
+ candle: OHLCVCandle;
21
+ timestamp: number;
22
+ }
23
+ interface OHLCVNewCandleData {
24
+ mint: string;
25
+ timeFrame: number;
26
+ candle: OHLCVCandle;
27
+ timestamp: number;
28
+ }
29
+ /**
30
+ * Hook to manage socket connection
31
+ * This is a simplified version for the NPM package
32
+ * Users should provide their own socket instance via props
33
+ */
34
+ export declare const useSocket: (socketInstance?: Socket | null) => {
35
+ socket: Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap> | null;
36
+ isConnected: boolean;
37
+ isConnecting: boolean;
38
+ connect: () => void;
39
+ disconnect: () => void;
40
+ subscribeToOHLCV: (mint: string, timeFrame?: number, onInitialData?: (data: OHLCVInitialData) => void, onUpdate?: (data: OHLCVUpdateData) => void, onNewCandle?: (data: OHLCVNewCandleData) => void) => boolean;
41
+ unsubscribeFromOHLCV: (mint: string, timeFrame?: number, onInitialData?: (data: OHLCVInitialData) => void, onUpdate?: (data: OHLCVUpdateData) => void, onNewCandle?: (data: OHLCVNewCandleData) => void) => boolean;
42
+ subscribeToPrice: (mint: string, onPriceUpdate?: (data: any) => void) => boolean;
43
+ unsubscribeFromPrice: (mint: string, onPriceUpdate?: (data: any) => void) => boolean;
44
+ testConnection: (message: string) => boolean;
45
+ };
46
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Funhi Chart - Professional Real-Time Trading Chart Component
3
+ *
4
+ * A powerful React chart component powered by TradingView's Lightweight Charts
5
+ * with built-in WebSocket support for real-time data updates.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { default as FunhiChart } from './components/FunhiChart';
10
+ export { default as ProfessionalTradingChartRedux } from './components/FunhiChart';
11
+ export type { ChartProps } from './components/FunhiChart';
12
+ export { useSocket } from './hooks/useSocket';
13
+ export { useOptimizedTokenAnalytics } from './hooks/useOptimizedTokenAnalytics';
14
+ export { candleStorageService } from './services/candleStorage';
15
+ export type { CandleData, SaveCandlesRequest, GetCandlesRequest, SaveCandleRequest } from './services/candleStorage';
16
+ export { candleAggregation } from './utils/candleAggregation';
17
+ export type { TimeFrame } from './utils/candleAggregation';
18
+ export { API_CONFIG } from './config/environment';
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Candle Storage Service
3
+ * Handles saving and retrieving candles from database via API
4
+ * Replaces localStorage with database storage for persistent candle data
5
+ */
6
+ export interface CandleData {
7
+ time: number;
8
+ open: number;
9
+ high: number;
10
+ low: number;
11
+ close: number;
12
+ volume: number;
13
+ }
14
+ export interface SaveCandlesRequest {
15
+ mint: string;
16
+ candles: CandleData[];
17
+ timeFrame?: number;
18
+ }
19
+ export interface GetCandlesRequest {
20
+ mint: string;
21
+ timeFrame?: number;
22
+ limit?: number;
23
+ }
24
+ export interface SaveCandleRequest {
25
+ mint: string;
26
+ candle: CandleData;
27
+ timeFrame?: number;
28
+ }
29
+ declare class CandleStorageService {
30
+ private readonly baseURL;
31
+ private savingQueue;
32
+ private readonly BATCH_DELAY;
33
+ private readonly BATCH_SIZE;
34
+ /**
35
+ * Save multiple candles to database
36
+ * Uses batching to reduce API calls
37
+ */
38
+ saveCandles(request: SaveCandlesRequest): Promise<boolean>;
39
+ /**
40
+ * Save a single candle to database
41
+ * Batches candles to reduce API calls
42
+ */
43
+ saveCandle(request: SaveCandleRequest): Promise<boolean>;
44
+ /**
45
+ * Flush the batching queue and save to database
46
+ */
47
+ private flushQueue;
48
+ /**
49
+ * Get candles from database
50
+ */
51
+ getCandles(request: GetCandlesRequest): Promise<CandleData[]>;
52
+ /**
53
+ * Flush all pending queues before component unmount
54
+ */
55
+ flushAll(): Promise<void>;
56
+ }
57
+ export declare const candleStorageService: CandleStorageService;
58
+ export {};
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Candle Aggregation Utility
3
+ *
4
+ * Client-side aggregation of 1-minute candles into larger timeframes
5
+ * This provides real-time aggregation without waiting for server responses
6
+ */
7
+ export interface CandleData {
8
+ time: number;
9
+ open: number;
10
+ high: number;
11
+ low: number;
12
+ close: number;
13
+ volume: number;
14
+ }
15
+ export interface TimeFrame {
16
+ label: string;
17
+ value: string;
18
+ seconds: number;
19
+ }
20
+ declare class CandleAggregation {
21
+ private timeframes;
22
+ /**
23
+ * Aggregate 1-minute candles into a larger timeframe
24
+ */
25
+ aggregateCandles(oneMinuteCandles: CandleData[], targetTimeframe: number): CandleData[];
26
+ /**
27
+ * Aggregate a group of candles into a single candle
28
+ */
29
+ private aggregateGroup;
30
+ /**
31
+ * Get human-readable timeframe label
32
+ */
33
+ getTimeframeLabel(seconds: number): string;
34
+ /**
35
+ * Get timeframe in seconds from label
36
+ */
37
+ getTimeframeSeconds(label: string): number;
38
+ /**
39
+ * Fill gaps in candles with flat candles (same OHLC)
40
+ * This ensures continuous chart rendering
41
+ */
42
+ fillGaps(candles: CandleData[], timeframe: number): CandleData[];
43
+ /**
44
+ * Get the current incomplete candle for a timeframe
45
+ * This is used for real-time updates
46
+ */
47
+ getCurrentCandle(oneMinuteCandles: CandleData[], targetTimeframe: number): CandleData | null;
48
+ /**
49
+ * Update real-time candle with new 1-minute candle
50
+ * Returns updated array of aggregated candles
51
+ */
52
+ updateRealtimeCandle(aggregatedCandles: CandleData[], newOneMinuteCandle: CandleData, targetTimeframe: number): CandleData[];
53
+ /**
54
+ * Validate candle data structure
55
+ */
56
+ isValidCandle(candle: any): candle is CandleData;
57
+ /**
58
+ * Clean invalid candles from array
59
+ */
60
+ cleanCandles(candles: CandleData[]): CandleData[];
61
+ /**
62
+ * Get the minimum number of 1-minute candles needed for a timeframe
63
+ */
64
+ getRequiredOneMinuteCandles(targetTimeframe: number, targetCount?: number): number;
65
+ }
66
+ export declare const candleAggregation: CandleAggregation;
67
+ export {};
@@ -0,0 +1,295 @@
1
+ import React from 'react';
2
+ import * as _socket_io_component_emitter from '@socket.io/component-emitter';
3
+ import { Socket } from 'socket.io-client';
4
+
5
+ interface ChartProps {
6
+ mint: string;
7
+ ticker?: string;
8
+ tokenName?: string;
9
+ socket?: any;
10
+ isConnected?: boolean;
11
+ currentMarketCap?: number;
12
+ analyticsConnected?: boolean;
13
+ analyticsLoading?: boolean;
14
+ }
15
+ declare const FunhiChart: React.FC<ChartProps>;
16
+
17
+ interface OHLCVCandle {
18
+ time: number;
19
+ open: number;
20
+ high: number;
21
+ low: number;
22
+ close: number;
23
+ volume: number;
24
+ }
25
+ interface OHLCVInitialData {
26
+ mint: string;
27
+ timeFrame: number;
28
+ data: OHLCVCandle[];
29
+ timestamp: number;
30
+ error?: string;
31
+ }
32
+ interface OHLCVUpdateData {
33
+ mint: string;
34
+ timeFrame: number;
35
+ candle: OHLCVCandle;
36
+ timestamp: number;
37
+ }
38
+ interface OHLCVNewCandleData {
39
+ mint: string;
40
+ timeFrame: number;
41
+ candle: OHLCVCandle;
42
+ timestamp: number;
43
+ }
44
+ /**
45
+ * Hook to manage socket connection
46
+ * This is a simplified version for the NPM package
47
+ * Users should provide their own socket instance via props
48
+ */
49
+ declare const useSocket: (socketInstance?: Socket | null) => {
50
+ socket: Socket<_socket_io_component_emitter.DefaultEventsMap, _socket_io_component_emitter.DefaultEventsMap> | null;
51
+ isConnected: boolean;
52
+ isConnecting: boolean;
53
+ connect: () => void;
54
+ disconnect: () => void;
55
+ subscribeToOHLCV: (mint: string, timeFrame?: number, onInitialData?: (data: OHLCVInitialData) => void, onUpdate?: (data: OHLCVUpdateData) => void, onNewCandle?: (data: OHLCVNewCandleData) => void) => boolean;
56
+ unsubscribeFromOHLCV: (mint: string, timeFrame?: number, onInitialData?: (data: OHLCVInitialData) => void, onUpdate?: (data: OHLCVUpdateData) => void, onNewCandle?: (data: OHLCVNewCandleData) => void) => boolean;
57
+ subscribeToPrice: (mint: string, onPriceUpdate?: (data: any) => void) => boolean;
58
+ unsubscribeFromPrice: (mint: string, onPriceUpdate?: (data: any) => void) => boolean;
59
+ testConnection: (message: string) => boolean;
60
+ };
61
+
62
+ interface ComprehensiveAnalytics {
63
+ performance: {
64
+ '24H': {
65
+ gain: number;
66
+ percentage: string;
67
+ isPositive: boolean;
68
+ };
69
+ '7D': {
70
+ gain: number;
71
+ percentage: string;
72
+ isPositive: boolean;
73
+ };
74
+ '1M': {
75
+ gain: number;
76
+ percentage: string;
77
+ isPositive: boolean;
78
+ };
79
+ 'All Time': {
80
+ gain: number;
81
+ percentage: string;
82
+ isPositive: boolean;
83
+ };
84
+ };
85
+ market: {
86
+ marketValue: string;
87
+ price: string;
88
+ marketCap: string;
89
+ circulating: string;
90
+ totalSupply: string;
91
+ };
92
+ '24H': {
93
+ high: string;
94
+ low: string;
95
+ volume: string;
96
+ return: string;
97
+ };
98
+ volume: {
99
+ current: string;
100
+ '24h': string;
101
+ unit: string;
102
+ };
103
+ blockchain: {
104
+ currentRealSol: string;
105
+ realSolReserves: number;
106
+ virtualSolReserves: number;
107
+ tokenReserves: number;
108
+ };
109
+ additional: {
110
+ solUsdPrice: string;
111
+ timestamp: number;
112
+ };
113
+ }
114
+ interface EnhancedTokenAnalytics {
115
+ analytics: ComprehensiveAnalytics | null;
116
+ currentPrice: number;
117
+ currentMarketCap: number;
118
+ currentVolume: number;
119
+ performance24h: {
120
+ value: string;
121
+ isPositive: boolean;
122
+ raw: number;
123
+ };
124
+ performance7d: {
125
+ value: string;
126
+ isPositive: boolean;
127
+ raw: number;
128
+ };
129
+ performance1m: {
130
+ value: string;
131
+ isPositive: boolean;
132
+ raw: number;
133
+ };
134
+ performanceAllTime: {
135
+ value: string;
136
+ isPositive: boolean;
137
+ raw: number;
138
+ };
139
+ high24h: number;
140
+ low24h: number;
141
+ volume24h: number;
142
+ return24h: number;
143
+ loading: boolean;
144
+ error: string | null;
145
+ connected: boolean;
146
+ lastUpdate: number | null;
147
+ isRealVolume: (volume: number) => boolean;
148
+ }
149
+ /**
150
+ * Simplified hook for token analytics
151
+ * This is a stub version for the NPM package
152
+ * Users should provide their own analytics data or implement their own hook
153
+ */
154
+ declare function useOptimizedTokenAnalytics(mint: string | undefined, analyticsData?: any): EnhancedTokenAnalytics;
155
+
156
+ /**
157
+ * Candle Storage Service
158
+ * Handles saving and retrieving candles from database via API
159
+ * Replaces localStorage with database storage for persistent candle data
160
+ */
161
+ interface CandleData$1 {
162
+ time: number;
163
+ open: number;
164
+ high: number;
165
+ low: number;
166
+ close: number;
167
+ volume: number;
168
+ }
169
+ interface SaveCandlesRequest {
170
+ mint: string;
171
+ candles: CandleData$1[];
172
+ timeFrame?: number;
173
+ }
174
+ interface GetCandlesRequest {
175
+ mint: string;
176
+ timeFrame?: number;
177
+ limit?: number;
178
+ }
179
+ interface SaveCandleRequest {
180
+ mint: string;
181
+ candle: CandleData$1;
182
+ timeFrame?: number;
183
+ }
184
+ declare class CandleStorageService {
185
+ private readonly baseURL;
186
+ private savingQueue;
187
+ private readonly BATCH_DELAY;
188
+ private readonly BATCH_SIZE;
189
+ /**
190
+ * Save multiple candles to database
191
+ * Uses batching to reduce API calls
192
+ */
193
+ saveCandles(request: SaveCandlesRequest): Promise<boolean>;
194
+ /**
195
+ * Save a single candle to database
196
+ * Batches candles to reduce API calls
197
+ */
198
+ saveCandle(request: SaveCandleRequest): Promise<boolean>;
199
+ /**
200
+ * Flush the batching queue and save to database
201
+ */
202
+ private flushQueue;
203
+ /**
204
+ * Get candles from database
205
+ */
206
+ getCandles(request: GetCandlesRequest): Promise<CandleData$1[]>;
207
+ /**
208
+ * Flush all pending queues before component unmount
209
+ */
210
+ flushAll(): Promise<void>;
211
+ }
212
+ declare const candleStorageService: CandleStorageService;
213
+
214
+ /**
215
+ * Candle Aggregation Utility
216
+ *
217
+ * Client-side aggregation of 1-minute candles into larger timeframes
218
+ * This provides real-time aggregation without waiting for server responses
219
+ */
220
+ interface CandleData {
221
+ time: number;
222
+ open: number;
223
+ high: number;
224
+ low: number;
225
+ close: number;
226
+ volume: number;
227
+ }
228
+ interface TimeFrame {
229
+ label: string;
230
+ value: string;
231
+ seconds: number;
232
+ }
233
+ declare class CandleAggregation {
234
+ private timeframes;
235
+ /**
236
+ * Aggregate 1-minute candles into a larger timeframe
237
+ */
238
+ aggregateCandles(oneMinuteCandles: CandleData[], targetTimeframe: number): CandleData[];
239
+ /**
240
+ * Aggregate a group of candles into a single candle
241
+ */
242
+ private aggregateGroup;
243
+ /**
244
+ * Get human-readable timeframe label
245
+ */
246
+ getTimeframeLabel(seconds: number): string;
247
+ /**
248
+ * Get timeframe in seconds from label
249
+ */
250
+ getTimeframeSeconds(label: string): number;
251
+ /**
252
+ * Fill gaps in candles with flat candles (same OHLC)
253
+ * This ensures continuous chart rendering
254
+ */
255
+ fillGaps(candles: CandleData[], timeframe: number): CandleData[];
256
+ /**
257
+ * Get the current incomplete candle for a timeframe
258
+ * This is used for real-time updates
259
+ */
260
+ getCurrentCandle(oneMinuteCandles: CandleData[], targetTimeframe: number): CandleData | null;
261
+ /**
262
+ * Update real-time candle with new 1-minute candle
263
+ * Returns updated array of aggregated candles
264
+ */
265
+ updateRealtimeCandle(aggregatedCandles: CandleData[], newOneMinuteCandle: CandleData, targetTimeframe: number): CandleData[];
266
+ /**
267
+ * Validate candle data structure
268
+ */
269
+ isValidCandle(candle: any): candle is CandleData;
270
+ /**
271
+ * Clean invalid candles from array
272
+ */
273
+ cleanCandles(candles: CandleData[]): CandleData[];
274
+ /**
275
+ * Get the minimum number of 1-minute candles needed for a timeframe
276
+ */
277
+ getRequiredOneMinuteCandles(targetTimeframe: number, targetCount?: number): number;
278
+ }
279
+ declare const candleAggregation: CandleAggregation;
280
+
281
+ /**
282
+ * Environment Configuration for Funhi Chart
283
+ *
284
+ * This file provides configuration for the chart component
285
+ * Users can override these values by passing them as props
286
+ */
287
+ declare const API_CONFIG: {
288
+ readonly BASE_URL: any;
289
+ readonly TIMEOUT: 10000;
290
+ readonly MAX_RETRIES: 3;
291
+ readonly RETRY_DELAY: 1000;
292
+ };
293
+
294
+ export { API_CONFIG, FunhiChart, FunhiChart as ProfessionalTradingChartRedux, candleAggregation, candleStorageService, useOptimizedTokenAnalytics, useSocket };
295
+ export type { CandleData$1 as CandleData, ChartProps, GetCandlesRequest, SaveCandleRequest, SaveCandlesRequest, TimeFrame };