@one_deploy/sdk 1.0.7 → 1.2.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.
Files changed (106) hide show
  1. package/README.md +339 -0
  2. package/dist/ForexPoolDataGenerator--__twRwl.d.mts +76 -0
  3. package/dist/ForexPoolDataGenerator-eUgwsU_B.d.ts +76 -0
  4. package/dist/OneForexTradeHistory-TlKxjbFF.d.ts +250 -0
  5. package/dist/OneForexTradeHistory-iDySMcw0.d.mts +250 -0
  6. package/dist/components/index.d.mts +539 -0
  7. package/dist/components/index.d.ts +539 -0
  8. package/dist/components/index.js +7295 -0
  9. package/dist/components/index.js.map +1 -0
  10. package/dist/components/index.mjs +7243 -0
  11. package/dist/components/index.mjs.map +1 -0
  12. package/dist/config/index.d.mts +1 -0
  13. package/dist/config/index.d.ts +1 -0
  14. package/dist/console-BfTMA7ah.d.mts +504 -0
  15. package/dist/console-BfTMA7ah.d.ts +504 -0
  16. package/dist/hooks/index.d.mts +323 -1
  17. package/dist/hooks/index.d.ts +323 -1
  18. package/dist/hooks/index.js +3223 -0
  19. package/dist/hooks/index.js.map +1 -1
  20. package/dist/hooks/index.mjs +3204 -1
  21. package/dist/hooks/index.mjs.map +1 -1
  22. package/dist/index.d.mts +18 -352
  23. package/dist/index.d.ts +18 -352
  24. package/dist/index.js +8646 -574
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +8449 -432
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/providers/index.d.mts +31 -31
  29. package/dist/providers/index.d.ts +31 -31
  30. package/dist/providers/index.js +140 -153
  31. package/dist/providers/index.js.map +1 -1
  32. package/dist/providers/index.mjs +100 -109
  33. package/dist/providers/index.mjs.map +1 -1
  34. package/dist/react-native.d.mts +8 -144
  35. package/dist/react-native.d.ts +8 -144
  36. package/dist/react-native.js +2640 -689
  37. package/dist/react-native.js.map +1 -1
  38. package/dist/react-native.mjs +2610 -691
  39. package/dist/react-native.mjs.map +1 -1
  40. package/dist/services/index.d.mts +85 -4
  41. package/dist/services/index.d.ts +85 -4
  42. package/dist/services/index.js +1621 -0
  43. package/dist/services/index.js.map +1 -1
  44. package/dist/services/index.mjs +1619 -1
  45. package/dist/services/index.mjs.map +1 -1
  46. package/dist/types/index.d.mts +203 -1
  47. package/dist/types/index.d.ts +203 -1
  48. package/dist/types/index.js +275 -0
  49. package/dist/types/index.js.map +1 -1
  50. package/dist/types/index.mjs +251 -0
  51. package/dist/types/index.mjs.map +1 -1
  52. package/dist/useForexTrading-BleeSor8.d.mts +80 -0
  53. package/dist/useForexTrading-ZgW_G40Q.d.ts +80 -0
  54. package/package.json +9 -2
  55. package/src/components/OneConnectButton.tsx +24 -1
  56. package/src/components/OneNFTGallery.tsx +13 -7
  57. package/src/components/OneOfframpWidget.tsx +4 -3
  58. package/src/components/OnePayWidget.tsx +10 -1
  59. package/src/components/OneSendWidget.tsx +3 -3
  60. package/src/components/OneSwapWidget.tsx +4 -4
  61. package/src/components/OneTransactionButton.tsx +28 -3
  62. package/src/components/OneWalletBalance.tsx +1 -1
  63. package/src/components/ai/OneChainSelector.tsx +63 -336
  64. package/src/components/ai/OneForexCapitalSplit.tsx +112 -0
  65. package/src/components/ai/OneForexConsoleView.tsx +90 -0
  66. package/src/components/ai/OneForexPairSelector.tsx +101 -0
  67. package/src/components/ai/OneForexPoolCard.tsx +105 -0
  68. package/src/components/ai/OneForexTradeHistory.tsx +107 -0
  69. package/src/components/ai/OnePairSelector.tsx +77 -434
  70. package/src/components/ai/console/OneAIQuantConsole.tsx +423 -0
  71. package/src/components/ai/console/OneAgentCard.tsx +383 -0
  72. package/src/components/ai/console/OneAgentConsole.tsx +469 -0
  73. package/src/components/ai/console/OneDecisionTimeline.tsx +433 -0
  74. package/src/components/ai/console/OneMetricsDashboard.tsx +493 -0
  75. package/src/components/ai/console/OnePositionCard.tsx +406 -0
  76. package/src/components/ai/console/OnePositionDetail.tsx +600 -0
  77. package/src/components/ai/console/OneRiskIndicator.tsx +464 -0
  78. package/src/components/ai/console/OneTradingConsole.tsx +660 -0
  79. package/src/components/ai/console/index.ts +17 -0
  80. package/src/components/ai/index.ts +10 -0
  81. package/src/hooks/index.ts +46 -0
  82. package/src/hooks/useAIDecisions.ts +280 -0
  83. package/src/hooks/useAIPositions.ts +349 -0
  84. package/src/hooks/useAIQuantConsole.ts +283 -0
  85. package/src/hooks/useAIRiskStatus.ts +276 -0
  86. package/src/hooks/useAITrading.ts +190 -0
  87. package/src/hooks/useBotSimulation.ts +201 -0
  88. package/src/hooks/useForexTrading.ts +430 -0
  89. package/src/hooks/useTradingConsole.ts +243 -0
  90. package/src/index.ts +123 -5
  91. package/src/providers/OneProvider.tsx +181 -5
  92. package/src/providers/index.ts +22 -8
  93. package/src/react-native.ts +41 -0
  94. package/src/services/forex/BotSimulationEngine.ts +968 -0
  95. package/src/services/forex/ForexPoolDataGenerator.ts +542 -0
  96. package/src/services/forex/ForexSimulationEngine.ts +482 -0
  97. package/src/services/forex/index.ts +21 -0
  98. package/src/services/index.ts +16 -0
  99. package/src/types/aiTrading.ts +151 -0
  100. package/src/types/console.ts +380 -0
  101. package/src/types/forex.ts +282 -0
  102. package/src/types/index.ts +106 -0
  103. package/dist/price-CgqXPnT3.d.ts +0 -13
  104. package/dist/price-ClbLHHjv.d.mts +0 -13
  105. package/dist/supabase-BT0c7q9e.d.mts +0 -82
  106. package/dist/supabase-BT0c7q9e.d.ts +0 -82
@@ -0,0 +1,406 @@
1
+ /**
2
+ * OnePositionCard - Displays position with live P&L
3
+ * Part of ONE Ecosystem SDK
4
+ */
5
+
6
+ import React from 'react';
7
+ import { View, Text, StyleSheet, TouchableOpacity, ViewStyle, Platform } from 'react-native';
8
+ import type { AIPosition } from '../../../types/console';
9
+ import { formatPnl, formatPercent } from '../../../types/console';
10
+
11
+ const MONO = Platform.OS === 'ios' ? 'Courier New' : 'monospace';
12
+
13
+ export interface OnePositionCardProps {
14
+ position: AIPosition;
15
+ onPress?: (position: AIPosition) => void;
16
+ onClose?: (positionId: string) => void;
17
+ showDetails?: boolean;
18
+ showRiskLevels?: boolean;
19
+ compact?: boolean;
20
+ style?: ViewStyle;
21
+ dark?: boolean;
22
+ }
23
+
24
+ export const OnePositionCard: React.FC<OnePositionCardProps> = ({
25
+ position,
26
+ onPress,
27
+ onClose,
28
+ showDetails = true,
29
+ showRiskLevels = true,
30
+ compact = false,
31
+ style,
32
+ dark = true,
33
+ }) => {
34
+ const bg = dark ? '#111111' : '#ffffff';
35
+ const border = dark ? '#2A2A35' : '#E5E7EB';
36
+ const textPrimary = dark ? '#ffffff' : '#111827';
37
+ const textSecondary = dark ? '#9CA3AF' : '#6B7280';
38
+ const textMuted = dark ? '#555560' : '#9CA3AF';
39
+
40
+ const isLong = position.side === 'LONG';
41
+ const sideColor = isLong ? '#10B981' : '#EF4444';
42
+ const sideBgColor = isLong ? '#D1FAE5' : '#FEE2E2';
43
+ const pnlColor = position.pnl >= 0 ? '#10B981' : '#EF4444';
44
+
45
+ const handlePress = () => {
46
+ if (onPress) {
47
+ onPress(position);
48
+ }
49
+ };
50
+
51
+ const handleClose = () => {
52
+ if (onClose) {
53
+ onClose(position.id);
54
+ }
55
+ };
56
+
57
+ const formatPrice = (price: number): string => {
58
+ if (price >= 1000) return price.toFixed(2);
59
+ if (price >= 1) return price.toFixed(3);
60
+ return price.toFixed(5);
61
+ };
62
+
63
+ const openDuration = Date.now() - position.openTime;
64
+ const hours = Math.floor(openDuration / 3600000);
65
+ const minutes = Math.floor((openDuration % 3600000) / 60000);
66
+ const durationText = hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`;
67
+
68
+ // Render compact content
69
+ const renderCompactContent = () => (
70
+ <>
71
+ <View style={[styles.sideBadge, { backgroundColor: sideBgColor }]}>
72
+ <Text style={[styles.sideText, { color: sideColor }]}>{position.side}</Text>
73
+ </View>
74
+ <Text style={[styles.compactPair, { color: textPrimary }]}>{position.pair}</Text>
75
+ <Text style={[styles.compactLeverage, { color: textMuted }]}>{position.leverage}x</Text>
76
+ <Text style={[styles.compactPnl, { color: pnlColor }]}>
77
+ {formatPnl(position.pnl)}
78
+ </Text>
79
+ </>
80
+ );
81
+
82
+ // Render full content
83
+ const renderFullContent = () => (
84
+ <>
85
+ {/* Header */}
86
+ <View style={styles.header}>
87
+ <View style={styles.headerLeft}>
88
+ <View style={[styles.sideBadge, { backgroundColor: sideBgColor }]}>
89
+ <Text style={[styles.sideText, { color: sideColor }]}>{position.side}</Text>
90
+ </View>
91
+ <Text style={[styles.pair, { color: textPrimary }]}>{position.pair}</Text>
92
+ <Text style={[styles.leverage, { color: textSecondary }]}>{position.leverage}x</Text>
93
+ </View>
94
+ <View style={styles.headerRight}>
95
+ <Text style={[styles.pnl, { color: pnlColor }]}>
96
+ {formatPnl(position.pnl)}
97
+ </Text>
98
+ <Text style={[styles.pnlPercent, { color: pnlColor }]}>
99
+ {formatPercent(position.pnlPercent)}
100
+ </Text>
101
+ </View>
102
+ </View>
103
+
104
+ {/* Price Info */}
105
+ <View style={styles.priceRow}>
106
+ <View style={styles.priceItem}>
107
+ <Text style={[styles.priceLabel, { color: textMuted }]}>Entry</Text>
108
+ <Text style={[styles.priceValue, { color: textSecondary }]}>
109
+ ${formatPrice(position.entryPrice)}
110
+ </Text>
111
+ </View>
112
+ <View style={styles.priceItem}>
113
+ <Text style={[styles.priceLabel, { color: textMuted }]}>Current</Text>
114
+ <Text style={[styles.priceValue, { color: textPrimary }]}>
115
+ ${formatPrice(position.currentPrice)}
116
+ </Text>
117
+ </View>
118
+ <View style={styles.priceItem}>
119
+ <Text style={[styles.priceLabel, { color: textMuted }]}>Size</Text>
120
+ <Text style={[styles.priceValue, { color: textSecondary }]}>
121
+ ${position.size.toFixed(0)}
122
+ </Text>
123
+ </View>
124
+ </View>
125
+
126
+ {/* Risk Levels */}
127
+ {showRiskLevels && (position.stopLoss || position.takeProfit) && (
128
+ <View style={styles.riskRow}>
129
+ {position.stopLoss && (
130
+ <View style={styles.riskItem}>
131
+ <Text style={[styles.riskLabel, { color: '#EF4444' }]}>SL</Text>
132
+ <Text style={[styles.riskValue, { color: textSecondary }]}>
133
+ ${formatPrice(position.stopLoss)}
134
+ </Text>
135
+ </View>
136
+ )}
137
+ {position.takeProfit && (
138
+ <View style={styles.riskItem}>
139
+ <Text style={[styles.riskLabel, { color: '#10B981' }]}>TP</Text>
140
+ <Text style={[styles.riskValue, { color: textSecondary }]}>
141
+ ${formatPrice(position.takeProfit)}
142
+ </Text>
143
+ </View>
144
+ )}
145
+ {position.liquidationPrice && (
146
+ <View style={styles.riskItem}>
147
+ <Text style={[styles.riskLabel, { color: '#F59E0B' }]}>LIQ</Text>
148
+ <Text style={[styles.riskValue, { color: textSecondary }]}>
149
+ ${formatPrice(position.liquidationPrice)}
150
+ </Text>
151
+ </View>
152
+ )}
153
+ </View>
154
+ )}
155
+
156
+ {/* Details */}
157
+ {showDetails && (
158
+ <View style={styles.detailsRow}>
159
+ <View style={styles.detailItem}>
160
+ <Text style={[styles.detailLabel, { color: textMuted }]}>Strategy</Text>
161
+ <Text style={[styles.detailValue, { color: textSecondary }]}>
162
+ {position.strategyName}
163
+ </Text>
164
+ </View>
165
+ <View style={styles.detailItem}>
166
+ <Text style={[styles.detailLabel, { color: textMuted }]}>Duration</Text>
167
+ <Text style={[styles.detailValue, { color: textSecondary }]}>
168
+ {durationText}
169
+ </Text>
170
+ </View>
171
+ {position.chain && (
172
+ <View style={styles.detailItem}>
173
+ <Text style={[styles.detailLabel, { color: textMuted }]}>Chain</Text>
174
+ <Text style={[styles.detailValue, { color: textSecondary }]}>
175
+ {position.chain}
176
+ </Text>
177
+ </View>
178
+ )}
179
+ </View>
180
+ )}
181
+
182
+ {/* AI Reasoning */}
183
+ {position.aiReasoning && (
184
+ <View style={[styles.reasoningBox, { backgroundColor: dark ? '#1A1A1F' : '#F3F4F6' }]}>
185
+ <Text style={[styles.reasoningLabel, { color: textMuted }]}>AI Reasoning</Text>
186
+ <Text style={[styles.reasoningText, { color: textSecondary }]}>
187
+ {position.aiReasoning}
188
+ </Text>
189
+ {position.aiConfidence && (
190
+ <Text style={[styles.confidenceText, { color: textMuted }]}>
191
+ Confidence: {(position.aiConfidence * 100).toFixed(0)}%
192
+ </Text>
193
+ )}
194
+ </View>
195
+ )}
196
+
197
+ {/* Close Button */}
198
+ {onClose && position.status === 'open' && (
199
+ <TouchableOpacity
200
+ style={styles.closeButton}
201
+ onPress={handleClose}
202
+ activeOpacity={0.7}
203
+ >
204
+ <Text style={styles.closeButtonText}>Close Position</Text>
205
+ </TouchableOpacity>
206
+ )}
207
+ </>
208
+ );
209
+
210
+ if (compact) {
211
+ if (onPress) {
212
+ return (
213
+ <TouchableOpacity
214
+ style={[styles.compactContainer, { backgroundColor: bg, borderColor: border }, style]}
215
+ onPress={handlePress}
216
+ activeOpacity={0.7}
217
+ >
218
+ {renderCompactContent()}
219
+ </TouchableOpacity>
220
+ );
221
+ }
222
+ return (
223
+ <View style={[styles.compactContainer, { backgroundColor: bg, borderColor: border }, style]}>
224
+ {renderCompactContent()}
225
+ </View>
226
+ );
227
+ }
228
+
229
+ if (onPress) {
230
+ return (
231
+ <TouchableOpacity
232
+ style={[styles.container, { backgroundColor: bg, borderColor: border }, style]}
233
+ onPress={handlePress}
234
+ activeOpacity={0.7}
235
+ >
236
+ {renderFullContent()}
237
+ </TouchableOpacity>
238
+ );
239
+ }
240
+
241
+ return (
242
+ <View style={[styles.container, { backgroundColor: bg, borderColor: border }, style]}>
243
+ {renderFullContent()}
244
+ </View>
245
+ );
246
+ };
247
+
248
+ const styles = StyleSheet.create({
249
+ container: {
250
+ borderRadius: 12,
251
+ borderWidth: 1,
252
+ padding: 14,
253
+ gap: 12,
254
+ },
255
+ compactContainer: {
256
+ flexDirection: 'row',
257
+ alignItems: 'center',
258
+ borderRadius: 8,
259
+ borderWidth: 1,
260
+ paddingHorizontal: 12,
261
+ paddingVertical: 8,
262
+ gap: 10,
263
+ },
264
+ sideBadge: {
265
+ paddingHorizontal: 8,
266
+ paddingVertical: 3,
267
+ borderRadius: 4,
268
+ },
269
+ sideText: {
270
+ fontFamily: MONO,
271
+ fontSize: 10,
272
+ fontWeight: '700',
273
+ },
274
+ compactPair: {
275
+ fontFamily: MONO,
276
+ fontSize: 12,
277
+ fontWeight: '600',
278
+ flex: 1,
279
+ },
280
+ compactLeverage: {
281
+ fontFamily: MONO,
282
+ fontSize: 11,
283
+ },
284
+ compactPnl: {
285
+ fontFamily: MONO,
286
+ fontSize: 12,
287
+ fontWeight: '600',
288
+ },
289
+ header: {
290
+ flexDirection: 'row',
291
+ justifyContent: 'space-between',
292
+ alignItems: 'center',
293
+ },
294
+ headerLeft: {
295
+ flexDirection: 'row',
296
+ alignItems: 'center',
297
+ gap: 8,
298
+ },
299
+ headerRight: {
300
+ alignItems: 'flex-end',
301
+ },
302
+ pair: {
303
+ fontSize: 16,
304
+ fontWeight: '700',
305
+ },
306
+ leverage: {
307
+ fontFamily: MONO,
308
+ fontSize: 12,
309
+ },
310
+ pnl: {
311
+ fontFamily: MONO,
312
+ fontSize: 18,
313
+ fontWeight: '700',
314
+ },
315
+ pnlPercent: {
316
+ fontFamily: MONO,
317
+ fontSize: 12,
318
+ },
319
+ priceRow: {
320
+ flexDirection: 'row',
321
+ justifyContent: 'space-between',
322
+ },
323
+ priceItem: {
324
+ alignItems: 'center',
325
+ gap: 2,
326
+ },
327
+ priceLabel: {
328
+ fontFamily: MONO,
329
+ fontSize: 9,
330
+ textTransform: 'uppercase',
331
+ },
332
+ priceValue: {
333
+ fontFamily: MONO,
334
+ fontSize: 12,
335
+ },
336
+ riskRow: {
337
+ flexDirection: 'row',
338
+ justifyContent: 'space-around',
339
+ paddingVertical: 8,
340
+ borderTopWidth: 1,
341
+ borderTopColor: '#2A2A35',
342
+ borderBottomWidth: 1,
343
+ borderBottomColor: '#2A2A35',
344
+ },
345
+ riskItem: {
346
+ flexDirection: 'row',
347
+ alignItems: 'center',
348
+ gap: 6,
349
+ },
350
+ riskLabel: {
351
+ fontFamily: MONO,
352
+ fontSize: 10,
353
+ fontWeight: '700',
354
+ },
355
+ riskValue: {
356
+ fontFamily: MONO,
357
+ fontSize: 11,
358
+ },
359
+ detailsRow: {
360
+ flexDirection: 'row',
361
+ justifyContent: 'space-between',
362
+ },
363
+ detailItem: {
364
+ alignItems: 'center',
365
+ gap: 2,
366
+ },
367
+ detailLabel: {
368
+ fontFamily: MONO,
369
+ fontSize: 9,
370
+ textTransform: 'uppercase',
371
+ },
372
+ detailValue: {
373
+ fontFamily: MONO,
374
+ fontSize: 11,
375
+ },
376
+ reasoningBox: {
377
+ padding: 10,
378
+ borderRadius: 8,
379
+ gap: 4,
380
+ },
381
+ reasoningLabel: {
382
+ fontFamily: MONO,
383
+ fontSize: 9,
384
+ textTransform: 'uppercase',
385
+ },
386
+ reasoningText: {
387
+ fontSize: 12,
388
+ lineHeight: 18,
389
+ },
390
+ confidenceText: {
391
+ fontFamily: MONO,
392
+ fontSize: 10,
393
+ marginTop: 4,
394
+ },
395
+ closeButton: {
396
+ backgroundColor: '#EF4444',
397
+ paddingVertical: 10,
398
+ borderRadius: 8,
399
+ alignItems: 'center',
400
+ },
401
+ closeButtonText: {
402
+ color: '#ffffff',
403
+ fontWeight: '600',
404
+ fontSize: 14,
405
+ },
406
+ });